-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPathHead.example.test.ts
43 lines (42 loc) · 1.05 KB
/
PathHead.example.test.ts
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
import gql from "graphql-tag";
import map from "../src";
test("PathHead", () => {
const data = {
exampleObj: {
exampleStr: "hello world",
},
destinations: [
{
array_string: "foo",
},
{
array_string: "bar",
},
{
array_string: "baz",
},
],
};
const query = gql`
query PathHead {
exampleStr(from: "exampleObj.exampleStr")
exampleStrHead(from: "exampleObj.exampleStr", head: true)
exampleStrNoHead(from: "exampleObj.exampleStr", head: false)
destinationsHead(from: "destinations[*].array_string", head: true)
destinationsNoHead(from: "destinations[*].array_string", head: false)
destinations(from: "destinations[*].array_string")
}
`;
const result = map(query, data);
expect(result).toEqual(
//
{
destinations: "foo",
destinationsHead: "foo",
destinationsNoHead: ["foo", "bar", "baz"],
exampleStr: "hello world",
exampleStrHead: "hello world",
exampleStrNoHead: ["hello world"],
}
);
});