Created
January 4, 2019 02:40
-
-
Save CodingItWrong/5ed2255fdf2ca9e0900e1ba14fbaee9f 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
| describe('clicking send', () => { | |
| const messageText = 'Hello world'; | |
| + let sendHandler; | |
| let getByTestId; | |
| beforeEach(() => { | |
| + sendHandler = jest.fn(); | |
| - ({ getByTestId } = render(<NewMessageForm />)); | |
| + ({ getByTestId } = render(<NewMessageForm onSend={sendHandler} />)); | |
| fireEvent.changeText(getByTestId('messageText'), messageText); | |
| fireEvent.press(getByTestId('sendButton')); | |
| ... | |
| it('clears the message field', () => { | |
| expect(getByTestId('messageText').props.value).toEqual(''); | |
| }); | |
| + | |
| + it('calls the send handler', () => { | |
| + expect(sendHandler).toHaveBeenCalledWith(messageText); | |
| + }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment