Skip to content

Instantly share code, notes, and snippets.

@qswitcher
Created June 2, 2018 04:22
Show Gist options
  • Save qswitcher/adbe5d831207f2efa3cd20f220a83196 to your computer and use it in GitHub Desktop.
Save qswitcher/adbe5d831207f2efa3cd20f220a83196 to your computer and use it in GitHub Desktop.
test('entering a todo in form adds a todo', async () => {
// 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