chore(test): rewritten clickable table row component test using rtl (#4630)

This commit is contained in:
Tharun Rajendran 2022-03-19 00:40:29 +05:30 committed by GitHub
parent cb159970c1
commit c16ac4fcc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
import React from "react";
import { mount } from "enzyme";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import ClickableTableRow from "./index";
@ -13,14 +14,14 @@ const props = {
describe("ClickableTableRow - component", () => {
it("calls onDblClick when row is double clicked", () => {
const queryRow = mount(<ClickableTableRow {...props} />);
queryRow.find("tr").simulate("doubleclick");
render(<ClickableTableRow {...props} />);
userEvent.dblClick(screen.getByRole("row"));
expect(dblClickSpy).toHaveBeenCalled();
});
it("calls onSelect when row is clicked", () => {
const queryRow = mount(<ClickableTableRow {...props} />);
queryRow.find("tr").simulate("click");
render(<ClickableTableRow {...props} />);
userEvent.click(screen.getByRole("row"));
expect(clickSpy).toHaveBeenCalled();
});
});