Created
June 13, 2018 16:22
-
-
Save JakeDawkins/e6502eb1e876ac5e465c160630669ae2 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
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