import React, { PropsWithChildren } from "react"; import { render } from "@testing-library/react-native"; import { ThemeProvider } from "./theme/src/theme-context"; import { pearl } from "./pearl"; import { Text, View } from "react-native"; import { extendTheme } from "./theme/src/base/index"; import Box, { BoxProps } from "./components/atoms/box/box"; jest.useFakeTimers(); describe("pearl/basic", () => { const PearlViewComponent: React.FC = ({ children, ...props }) => { const PearlView = pearl(View, { componentName: "TestView", type: "basic", }); return {children}; }; const PearlTextComponent: React.FC = ({ children, ...props }) => { const PearlText = pearl(Text, { componentName: "TestText", type: "basic", }); return {children}; }; it("passes the snapshot test for a component", () => { const tree = render( ).toJSON(); expect(tree).toMatchSnapshot(); }); it("passes the snapshot test for a component", () => { const tree = render( asdasd ).toJSON(); expect(tree).toMatchSnapshot(); }); it("renders the correct children for a component", () => { const { getByText } = render( Test ); expect(getByText("Test")).toBeTruthy(); }); it("renders the correct children for a component", () => { const { getByText } = render( Test ); expect(getByText("Test")).toBeTruthy(); }); }); describe("pearl/atoms", () => { const newTheme = extendTheme({ components: { TestView: { baseStyle: { width: 200, height: 200, backgroundColor: "danger.400", boxShadow: "4xl", }, }, TestText: { baseStyle: { color: "success.400", fontFamily: "body", fontWeight: "hairline", }, }, }, }); const PearlViewComponent: React.FC = ({ children, ...props }) => { const PearlView = pearl(View, { componentName: "TestView", type: "atom", }); return {children}; }; const PearlTextComponent: React.FC = ({ children, ...props }) => { const PearlText = pearl(Text, { componentName: "TestText", type: "atom", }); return {children}; }; it("passes the snapshot test for a component", () => { const tree = render( ).toJSON(); expect(tree).toMatchSnapshot(); }); it("passes the snapshot test for a component", () => { const tree = render( asdasd ).toJSON(); expect(tree).toMatchSnapshot(); }); it("renders the correct children for a component", () => { const { getByText } = render( Test ); expect(getByText("Test")).toBeTruthy(); }); it("renders the correct children for a component", () => { const { getByText } = render( Test ); expect(getByText("Test")).toBeTruthy(); }); }); describe("pearl/molecules", () => { const newTheme = extendTheme({ components: { TestView: { parts: ["root", "box1", "box2"], baseStyle: { root: { width: 200, height: 200, backgroundColor: "danger.400", boxShadow: "4xl", p: "4xl", }, box1: { width: 50, height: 50, backgroundColor: "success.500", }, }, }, }, }); const PearlViewComponent: React.FC = ({ children, ...props }) => { const MoleculeRender = (props: any) => { return ( ); }; const PearlView = pearl(MoleculeRender, { componentName: "TestView", type: "molecule", }); return {children}; }; it("passes the snapshot test for a component", () => { const tree = render( ).toJSON(); expect(tree).toMatchSnapshot(); }); });