-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration-test.js
60 lines (55 loc) · 1.87 KB
/
integration-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const {InMemoryCache} = require("apollo-cache-inmemory");
const {HttpLink} = require("apollo-link-http");
const {ApolloClient} = require("apollo-client");
const fetch = require("node-fetch");
const gql = require('graphql-tag');
var uri = process.env.SERVER_URL || 'http://localhost:4000/';
const client = new ApolloClient({
link: new HttpLink({uri, fetch}),
cache: new InMemoryCache(),
});
describe('Json', () => {
it('can join across services', async () => {
let res = await client.query({
query: gql`query {
me {
username
reviews {
body
product {
name
upc
}
}
}
}`,
});
expect(res.data).toEqual({
"me": {
"__typename": "User",
"username": "Me",
"reviews": [
{
"__typename": "Review",
"body": "A highly effective form of birth control.",
"product": {
"__typename": "Product",
"name": "Trilby",
"upc": "top-1"
}
},
{
"__typename": "Review",
"body": "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.",
"product": {
"__typename": "Product",
"name": "Trilby",
"upc": "top-1"
}
}
]
}
});
expect(res.errors).toBe(undefined);
});
});