import React, { useState } from "react"; import Text from "../../components/atoms/text/text"; import { fireEvent, render } from "@testing-library/react-native"; import { ThemeProvider } from "../../theme/src/theme-context"; import Box from "../../components/atoms/box/box"; import { Pressable } from "react-native"; import { useColorScheme } from "../useColorScheme"; jest.useFakeTimers(); const TestComponent: React.FC = (props: any) => { const [useScheme, setUseScheme] = useState(false); const updatedObj = useColorScheme(props.colorScheme, props.object); return ( {useScheme ? updatedObj.color : props.object.color} setUseScheme(true)} testID="switchButton"> Use color scheme ); }; describe("useColorScheme", () => { it("leaves values unchanged for missing color scheme", () => { const { getByText, getByTestId } = render( ); expect(getByText("primary100")).toBeTruthy(); const toggleButton = getByTestId("switchButton"); fireEvent.press(toggleButton); expect(getByText("primary100")).toBeTruthy(); }); it("switches values containing primary to secondary", () => { const { getByText, getByTestId } = render( ); expect(getByText("primary100")).toBeTruthy(); const toggleButton = getByTestId("switchButton"); fireEvent.press(toggleButton); expect(getByText("secondary100")).toBeTruthy(); }); });