import React from 'react'; import { render, fireEvent } from '@testing-library/react-native'; import UnitChooser from "../UnitChooser"; import { Length } from 'convert'; describe('UnitChooser', () => { const mockOnChoicePressed = jest.fn(); const choices = ['foot', 'inch'] as Length []; it('renders correctly', () => { const { getByText } = render( ); choices.forEach(choice => { expect(getByText(choice)).toBeTruthy(); }); }); it('calls onChoicePressed when a button is pressed', () => { const { getByText } = render( ); fireEvent.press(getByText(choices[0])); expect(mockOnChoicePressed).toHaveBeenCalledWith(choices[0]); }); });