-
Notifications
You must be signed in to change notification settings - Fork 26
/
test.js
67 lines (61 loc) · 1.33 KB
/
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
60
61
62
63
64
65
66
67
var spok = require('spok')
var tape = require('tape')
var gql = require('./')
tape('should create a query', function (assert) {
var query = gql`
query($number_of_repos:Int!) {
viewer {
name
repositories(last: $number_of_repos) {
nodes {
name
}
}
}
}
`
var variables = { number_of_repos: 3 }
var data = query(variables)
spok(assert, JSON.parse(data), {
query: spok.string,
variables: JSON.stringify(variables)
})
assert.end()
})
tape('should have a name', function (assert) {
var query = gql`
query foo ($number_of_repos:Int!) {
viewer {
name
repositories(last: $number_of_repos) {
nodes {
name
}
}
}
}
`
var variables = { number_of_repos: 3 }
var data = query(variables)
spok(assert, JSON.parse(data), {
query: spok.string,
operationName: 'foo',
variables: JSON.stringify(variables)
})
assert.end()
})
tape('should have a name for mutations also', function (assert) {
var query = gql`
mutation CreateSomethingBig($input: Idea!) {
createSomething(input: $input) {
result
}
}
`
var data = query()
spok(assert, JSON.parse(data), {
query: spok.string,
operationName: 'CreateSomethingBig'
})
assert.end()
})