Last active
November 23, 2019 14:34
-
-
Save jaroslav-kubicek/421c7775075bae0942aa64a337308e46 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
// @flow | |
import * as React from 'react'; | |
import { mount } from 'enzyme'; | |
import { QueryRenderer, graphql } from '@adeira/relay'; | |
import { createMockEnvironment, MockPayloadGenerator } from 'relay-test-utils'; | |
describe('Component', () => { | |
it('Shows something', () => { | |
const environment = createMockEnvironment(); | |
const TestComponent = () => ( | |
<QueryRenderer | |
environment={environment} | |
query={graphql` | |
query TestQuery @relay_test_operation { | |
someQuery { | |
...YourFragment | |
} | |
} | |
`} | |
variables={{}} | |
onResponse={() => { | |
/* Render your fragment container */ | |
}} | |
/> | |
); | |
const wrapper = mount(<TestComponent />); | |
environment.mock.resolveMostRecentOperation(operation => | |
MockPayloadGenerator.generate(operation), | |
); | |
wrapper.update(); | |
// Test your stuff | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment