Skip to content

Commit 0e4d824

Browse files
committed
Add tests for prepareIsolatedFiles
1 parent 173e08e commit 0e4d824

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
query GetStuffIsolated {
2+
...FragIsolated
3+
things {
4+
existHere
5+
}
6+
}
7+
8+
fragment FragIsolated on Query {
9+
evenMoreStuff {
10+
stuffInside
11+
}
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
query GetStuffIsolated2 {
2+
things {
3+
existHere
4+
}
5+
}
6+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`builds out single operations 1`] = `
4+
Array [
5+
Object {
6+
"alias": null,
7+
"body": "query GetStuffIsolated {
8+
...FragIsolated
9+
things {
10+
existHere
11+
}
12+
}
13+
14+
fragment FragIsolated on Query {
15+
evenMoreStuff {
16+
stuffInside
17+
}
18+
}
19+
",
20+
"name": "GetStuffIsolated",
21+
},
22+
Object {
23+
"alias": null,
24+
"body": "query GetStuffIsolated2 {
25+
things {
26+
existHere
27+
}
28+
}
29+
",
30+
"name": "GetStuffIsolated2",
31+
},
32+
]
33+
`;
34+
35+
exports[`with --add-typename builds out single operations with __typename fields 1`] = `
36+
Array [
37+
Object {
38+
"alias": null,
39+
"body": "query GetStuffIsolated {
40+
...FragIsolated
41+
things {
42+
existHere
43+
__typename
44+
}
45+
}
46+
47+
fragment FragIsolated on Query {
48+
evenMoreStuff {
49+
stuffInside
50+
__typename
51+
}
52+
}
53+
",
54+
"name": "GetStuffIsolated",
55+
},
56+
Object {
57+
"alias": null,
58+
"body": "query GetStuffIsolated2 {
59+
things {
60+
existHere
61+
__typename
62+
}
63+
}
64+
",
65+
"name": "GetStuffIsolated2",
66+
},
67+
]
68+
`;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var prepareIsolatedFiles = require("../prepareIsolatedFiles")
2+
3+
it("builds out single operations", () => {
4+
var filenames = [
5+
"./__tests__/project/op_isolated_1.graphql",
6+
"./__tests__/project/op_isolated_2.graphql",
7+
]
8+
var ops = prepareIsolatedFiles(filenames, false)
9+
expect(ops).toMatchSnapshot()
10+
})
11+
12+
describe("with --add-typename", () => {
13+
it("builds out single operations with __typename fields", () => {
14+
var filenames = [
15+
"./__tests__/project/op_isolated_1.graphql",
16+
"./__tests__/project/op_isolated_2.graphql",
17+
]
18+
var ops = prepareIsolatedFiles(filenames, true)
19+
expect(ops).toMatchSnapshot()
20+
})
21+
})

0 commit comments

Comments
 (0)