import { fireEvent, render } from '@testing-library/react-native' import React from 'react' import 'react-native' import renderer from 'react-test-renderer' import { InitError } from './InitError' describe('InitError Component', () => { it('renders correctly', () => { // when we create the component then it should render correctly const instance = renderer.create( null} />) expect(instance.root.type).toBe(InitError) }) it('should call the handleInitApp function when the try again button is clicked', () => { // given ... we have created the component const onTryAgainPress = jest.fn() const { getByTestId } = render() // when ... we click the try again button const button = getByTestId('tryAgainButton') fireEvent.press(button) // then ... the onTryAgainPress function should be called expect(onTryAgainPress).toHaveBeenCalled() }) })