-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.ts
53 lines (48 loc) · 1.41 KB
/
utils_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
44
45
46
47
48
49
50
51
52
53
import { gql } from "./utils.ts";
import { describe, expect, it } from "./dev_deps.ts";
describe("gql", () => {
it("should trim left and right", () => {
expect(gql` query{hello} `).toBe("query{hello}");
});
it("should remove whitespace", () => {
expect(gql`query { hello }`).toBe("query{hello}");
});
it("should remove whitespace between word boundaries", () => {
expect(gql`query { hello world }`).toBe("query{hello world}");
});
it("should remove line break", () => {
expect(gql`query {
hello
world
}
`).toBe("query{hello world}");
});
it("should remove whitespace with arguments", () => {
expect(gql`query Test ($id : ID!)
{
hello (id : $id )
world
}
`).toBe("query Test($id:ID!){hello(id:$id)world}");
});
it("should remove when complex query", () => {
expect(gql`query Test ($ id : Id!)
{
hello (id : $id )
world
}
mutation TestMutate ($ id : Id!) {
crateUser ( id : $id )
}
`).toBe(
"query Test($id:Id!){hello(id:$id)world}mutation TestMutate($id:Id!){crateUser(id:$id)}",
);
});
it("should same when it is compressed", () => {
expect(
gql`query Test($id:Id!){hello(id:$id)world}mutation TestMutate($id:Id!){crateUser(id:$id)}`,
).toBe(
"query Test($id:Id!){hello(id:$id)world}mutation TestMutate($id:Id!){crateUser(id:$id)}",
);
});
});