2021-04-12 13:32:25 +00:00
|
|
|
import React from "react";
|
2022-09-12 15:10:10 +00:00
|
|
|
import { screen } from "@testing-library/react";
|
2017-02-24 22:47:32 +00:00
|
|
|
|
2022-09-12 15:10:10 +00:00
|
|
|
import { renderWithSetup } from "test/testingUtils";
|
2021-04-12 13:32:25 +00:00
|
|
|
import ClickableTableRow from "./index";
|
2017-02-24 22:47:32 +00:00
|
|
|
|
2020-12-01 18:15:12 +00:00
|
|
|
const clickSpy = jest.fn();
|
|
|
|
|
const dblClickSpy = jest.fn();
|
2017-02-24 22:47:32 +00:00
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
|
onClick: clickSpy,
|
|
|
|
|
onDoubleClick: dblClickSpy,
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
describe("ClickableTableRow - component", () => {
|
2022-09-12 15:10:10 +00:00
|
|
|
it("calls onDblClick when row is double clicked", async () => {
|
|
|
|
|
const { user } = renderWithSetup(<ClickableTableRow {...props} />);
|
|
|
|
|
await user.dblClick(screen.getByRole("row"));
|
2017-02-24 22:47:32 +00:00
|
|
|
expect(dblClickSpy).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
2022-09-12 15:10:10 +00:00
|
|
|
it("calls onSelect when row is clicked", async () => {
|
|
|
|
|
const { user } = renderWithSetup(<ClickableTableRow {...props} />);
|
|
|
|
|
await user.click(screen.getByRole("row"));
|
2017-02-24 22:47:32 +00:00
|
|
|
expect(clickSpy).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
});
|