import { render } from '@testing-library/react-native'; import * as React from 'react'; import { Switch, Text, View } from 'react-native'; import { SwitchListItem } from './SwitchListItem'; beforeEach(() => { jest.clearAllMocks(); jest.spyOn(console, 'error').mockImplementation(); jest.spyOn(console, 'info').mockImplementation(); }); describe('SwitchListItem', () => { it("renders the label on the left when labelPosition === 'left'", () => { const { toJSON } = render( labelComponent} value={false} testID="switch" onValueChange={() => {}} />, ); expect(toJSON()).toMatchInlineSnapshot(` labelComponent `); }); it("renders the label on the left when labelPosition === 'right'", () => { const { toJSON } = render( labelComponent} value={false} testID="switch" labelPosition="right" onValueChange={() => {}} />, ); expect(toJSON()).toMatchInlineSnapshot(` labelComponent `); }); it('renders the React Native Switch if no children is specified', () => { const { UNSAFE_getByType } = render( labelComponent} value={true} onValueChange={() => {}} />, ); expect(UNSAFE_getByType(Switch).props).toBeDefined(); }); it('hides the children from the accessibilityTree', () => { const { getByTestId } = render( labelComponent} value={true} onValueChange={() => {}}> , ); expect(getByTestId('custom-switch').props).toEqual( expect.objectContaining({ importantForAccessibility: 'no', accessibilityElementsHidden: true, }), ); }); }); jest.mock('../providers/AMAProvider', () => { const originalModule = jest.requireActual('../providers/AMAProvider'); return { ...originalModule, useAMAContext: () => { return { isScreenReaderEnabled: true, }; }, }; });