import * as React from "react"; import * as ReactDOM from "react-dom"; import CheckBox from "../components/Checkbox/index"; import { render, cleanup, Simulate } from "react-testing-library"; beforeEach(cleanup); describe("Checkbox working correctly", () => { it("rtc", () => { const clicked = jest.fn(); const id = "123"; const { getByTestId, container, rerender } = render( ); expect(getByTestId("input").checked).toBeFalsy(); rerender(); expect(getByTestId("input").checked).toBeTruthy(); }); it("check", () => { const clicked = jest.fn(); const { getByTestId } = render( ); Simulate.change(getByTestId("input")); expect(clicked).toHaveBeenCalled(); }); it("checkbox snapshot", () => { const clicked = jest.fn(); const { container } = render( ); expect(container).toMatchSnapshot(); }); });