Created
June 13, 2018 16:22
-
-
Save JakeDawkins/4a3be4e2085d406db824132a993cffbe 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 render loading state initially', () => { | |
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 | |
const tree = component.toJSON(); | |
expect(tree.children).toContain('Loading...'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment