Last active
July 30, 2018 02:58
-
-
Save qswitcher/05fec8415100210f5d0b88699e97d788 to your computer and use it in GitHub Desktop.
This file contains 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 { mount } from 'enzyme'; | |
import App from '../../App'; | |
test('entering a todo in form adds a todo', async () => { | |
wrapper = mount(<App />); | |
// enter todo text in textbox | |
wrapper.find('.TodoForm-input').instance().value = 'My new todo'; | |
// click Add | |
wrapper.find('.TodoForm-button').simulate('click'); | |
// wait for Todo to show up | |
await wait(wrapper, w => | |
w | |
.find('.TodoItem') | |
.at(3) | |
.exists() | |
); | |
// make sure form is cleared | |
expect(wrapper.find('.TodoForm-input').instance().value).toEqual(''); | |
// make sure todo was added | |
const newText = wrapper | |
.find('.TodoItem') | |
.at(3) | |
.find('.TodoItem-text') | |
.text(); | |
expect(newText).toEqual('My new todo'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment