import React from 'react' import 'react-native' import renderer from 'react-test-renderer' import { render, fireEvent } from '@testing-library/react-native' import { SecondScreen } from './SecondScreen' describe('Second Screen Component', () => { it('renders correctly', () => { // when we create the component then it should render correctly const instance = renderer.create( null} />) expect(instance.root.type).toBe(SecondScreen) }) it('should call the onNextPressed when the next button is pressed', () => { // given ... we have a Home screen component // ... we have a next pressed handler const onNextPressed = jest.fn() const { getByTestId } = render() // when ... we click the next button fireEvent.press(getByTestId('secondScreenButton')) // then ... onNextPressed should have been called as expected expect(onNextPressed).toHaveBeenCalled() }) })