fleet/frontend/components/ClickableTableRow/index.tests.jsx
Gabriel Hernandez f1995bf79e
Fleet UI update to testing tooling user-event library (#7514)
* adding FE testing documentation

* extend radio button tests

* update test to work with new user-events lib version

* more testing docs
2022-09-12 16:10:10 +01:00

27 lines
819 B
JavaScript

import React from "react";
import { screen } from "@testing-library/react";
import { renderWithSetup } from "test/testingUtils";
import ClickableTableRow from "./index";
const clickSpy = jest.fn();
const dblClickSpy = jest.fn();
const props = {
onClick: clickSpy,
onDoubleClick: dblClickSpy,
};
describe("ClickableTableRow - component", () => {
it("calls onDblClick when row is double clicked", async () => {
const { user } = renderWithSetup(<ClickableTableRow {...props} />);
await user.dblClick(screen.getByRole("row"));
expect(dblClickSpy).toHaveBeenCalled();
});
it("calls onSelect when row is clicked", async () => {
const { user } = renderWithSetup(<ClickableTableRow {...props} />);
await user.click(screen.getByRole("row"));
expect(clickSpy).toHaveBeenCalled();
});
});