-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathRowIndicator.test.tsx
More file actions
37 lines (34 loc) · 1.18 KB
/
RowIndicator.test.tsx
File metadata and controls
37 lines (34 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* @jest-environment jsdom
*/
import React from "react";
import { render, screen } from "@testing-library/react";
import * as Types from "./types";
import RowIndicator from "./RowIndicator";
const EXAMPLE_PROPS: Types.RowIndicatorProps = {
row: 0,
selected: false,
onSelect: jest.fn(),
width: 100,
};
describe("<RowIndicator />", () => {
test("renders with row number", () => {
render(<RowIndicator {...EXAMPLE_PROPS} />);
expect(document.querySelectorAll("div.Spreadsheet__header").length).toBe(1);
expect(screen.queryByText("1")).not.toBeNull();
});
test("renders with label", () => {
render(<RowIndicator {...EXAMPLE_PROPS} label="Example Label" />);
expect(document.querySelectorAll("div.Spreadsheet__header").length).toBe(1);
expect(screen.queryByText("Example Label")).not.toBeNull();
});
test("calls on select", () => {
render(<RowIndicator {...EXAMPLE_PROPS} />);
expect(document.querySelectorAll("div.Spreadsheet__header").length).toBe(1);
const indicator = document.querySelector(
"div.Spreadsheet__header"
) as HTMLTableCellElement;
indicator.click();
expect(EXAMPLE_PROPS.onSelect).toBeCalledTimes(1);
});
});