import * as React from 'react'; import { act } from 'react'; import { Text, View, type ViewStyle } from 'react-native'; import { mergeStyles, useFluentTheme } from '@fluentui-react-native/framework'; import { Pressable } from '@fluentui-react-native/pressable'; import * as renderer from 'react-test-renderer'; import { Shadow } from '../Shadow'; const backgroundColor = { backgroundColor: 'red' }; interface ShadowTestProps { displayText: string; depth: string; } const TestShadow: React.FunctionComponent = (props: ShadowTestProps) => { const theme = useFluentTheme(); return ( {props.displayText} ); }; const TestPressableWithAndWithoutShadow: React.FunctionComponent = () => { const theme = useFluentTheme(); return ( ); }; interface ShadowOnChildViewWithProps { childViewStyleProps: object; } const TestShadowOnChildViewWithProps: React.FunctionComponent = (props: ShadowOnChildViewWithProps) => { const theme = useFluentTheme(); return ( (props.childViewStyleProps, backgroundColor)}> {JSON.stringify(props.childViewStyleProps)} ); }; describe('Shadow component tests', () => { beforeAll(() => { jest.mock('react-native/Libraries/Utilities/Platform', () => ({ OS: 'macos', select: () => null, })); }); it('Shadow (depth=2)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Shadow (depth=4)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Shadow (depth=8)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Shadow (depth=16)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Shadow (depth=28)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Shadow (depth=64)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Brand shadow (depth=2)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Brand shadow (depth=4)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Brand shadow (depth=8)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Brand shadow (depth=16)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Brand shadow (depth=28)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Brand shadow (depth=64)', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Pressable that has a shadow vs. pressable without shadow', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Shadow on a child with margin and padding', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Shadow on a child with border radius', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); it('Shadow on a child with border width', () => { let component: renderer.ReactTestRenderer; act(() => { component = renderer.create(); }); expect(component!.toJSON()).toMatchSnapshot(); }); afterAll(() => { jest.unmock('react-native/Libraries/Utilities/Platform'); }); });