import React from "react"; import { render, fireEvent } from "@testing-library/react-native"; import Switch from "./switch"; import { ThemeProvider } from "../../../theme/src/theme-context"; import Text from "../../atoms/text/text"; jest.useFakeTimers(); describe("Molecules/Switch", () => { it("passes the snapshot test with default props", () => { const tree = render( Test ).toJSON(); expect(tree).toMatchSnapshot(); }); it("passes the snapshot test with isChecked prop", () => { const tree = render( Test ).toJSON(); expect(tree).toMatchSnapshot(); }); it("passes the snapshot test with isDisabled prop", () => { const tree = render( Test ).toJSON(); expect(tree).toMatchSnapshot(); }); it("checks if Switch is disabled", async () => { const onPress = jest.fn(); const { getByTestId } = await render( Test ); const switchInstance = getByTestId("testOnPress"); fireEvent.press(switchInstance); expect(onPress).toHaveBeenCalledTimes(0); }); });