Skip to content

Instantly share code, notes, and snippets.

@jbaxleyiii
Last active September 6, 2016 01:49
Show Gist options
  • Save jbaxleyiii/29cfe383fc3b25dad6156afcf832c2d1 to your computer and use it in GitHub Desktop.
Save jbaxleyiii/29cfe383fc3b25dad6156afcf832c2d1 to your computer and use it in GitHub Desktop.
it('executes a query', (done) => {
const query = gql` query people { allPeople(first: 1) { people { name } } }`;
const data = { allPeople: { people: [ { name: 'Luke Skywalker' } ] } };
const networkInterface = mockNetworkInterface({ request: { query }, result: { data } });
const client = new ApolloClient({ networkInterface });
const withGraphQL = graphql(query);
class Container extends Component {
componentWillReceiveProps(props) {
expect(props.data.loading).to.be.false;
expect(props.data.allPeople).to.deep.equal(data.allPeople);
done();
}
render() {
return null;
}
};
const ContainerWithData = withGraphQL(Container);
mount(<ApolloProvider client={client}><ContainerWithData /></ApolloProvider>);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment