Skip to content

Instantly share code, notes, and snippets.

@JakeDawkins
Created June 13, 2018 16:22
Show Gist options
  • Save JakeDawkins/e6502eb1e876ac5e465c160630669ae2 to your computer and use it in GitHub Desktop.
Save JakeDawkins/e6502eb1e876ac5e465c160630669ae2 to your computer and use it in GitHub Desktop.
it('should delete and give visual feedback', async () => {
const deleteDog = { name: 'Buck', breed: 'Poodle', id: 1 };
const mocks = [
{
request: {
query: DELETE_DOG_MUTATION,
variables: { name: 'Buck' },
},
result: { data: { deleteDog } },
},
];
const component = renderer.create(
<MockedProvider mocks={mocks} addTypename={false}>
<DeleteButton />
</MockedProvider>,
);
// find the button and simulate a click
const button = component.root.findByType('button');
button.props.onClick(); // fires the mutation
await wait(0);
const tree = component.toJSON();
expect(tree.children).toContain('Deleted!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment