Created
February 25, 2020 17:04
-
-
Save r3dm1ke/fdb6edb470227e92451cb9164683cb04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import {render, cleanup, fireEvent} from 'react-native-testing-library'; | |
| import App from './App'; | |
| afterEach(cleanup); | |
| describe('<App />', () => { | |
| it('should match snapshot', () => { | |
| const rendered = render(<App />).toJSON(); | |
| expect(rendered).toMatchSnapshot(); | |
| }); | |
| it('should set counter to 0', () => { | |
| const rendered = render(<App />); | |
| const counterComponent = rendered.getByTestId('counter'); | |
| expect(counterComponent.props.children).toContainEqual(0); | |
| }); | |
| it('should increase counter by 1', () => { | |
| const rendered = render(<App />); | |
| const counterComponent = rendered.getByTestId('counter'); | |
| const buttonComponent = rendered. getByTestId('button'); | |
| fireEvent(buttonComponent, 'press'); | |
| expect(counterComponent.props.children).toContainEqual(1); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment