Skip to content

Instantly share code, notes, and snippets.

@qswitcher
Created June 2, 2018 04:24
Show Gist options
  • Save qswitcher/29277cfb0d201b99b25f5ea934b4b38e to your computer and use it in GitHub Desktop.
Save qswitcher/29277cfb0d201b99b25f5ea934b4b38e to your computer and use it in GitHub Desktop.
test('entering a todo in form adds a todo', async () => {
const { getByText, getByPlaceholderText, getByTestId, container } = render(<App />);
// enter todo text in textbox
getByPlaceholderText('Enter todo text').value = 'My new todo';
// click Add
Simulate.click(getByText('Add'));
// wait for Todo to show up
await wait(() => getByText('My new todo'));
// make sure form is cleared
expect(getByTestId('TodoForm-input').value).toEqual('');
// make sure todo was added
expect(getByText('My new todo')).toBeDefined();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment