forked from sheerun/graphqlviz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
140 lines (133 loc) · 3.72 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import test from 'ava'
import fs from 'fs'
import graphqlviz from './'
import path from 'path'
test('render', t => {
var input = fs
.readFileSync(path.resolve(__dirname, 'test/input.json'))
.toString()
var output = fs
.readFileSync(path.resolve(__dirname, 'test/output-noargs.dot'))
.toString()
var computed =
graphqlviz.render(input, { theme: { field: { noargs: true } } }) + '\n'
t.deepEqual(computed, output)
})
test('render with args', t => {
var input = fs
.readFileSync(path.resolve(__dirname, 'test/input.json'))
.toString()
var output = fs
.readFileSync(path.resolve(__dirname, 'test/output.dot'))
.toString()
var computed = graphqlviz.render(input, {}) + '\n'
t.deepEqual(computed, output)
})
test('render with sort', t => {
var input = fs
.readFileSync(path.resolve(__dirname, 'test/input.json'))
.toString()
var output = fs
.readFileSync(path.resolve(__dirname, 'test/output-sort.dot'))
.toString()
var computed =
graphqlviz.render(input, { theme: { field: { sort: true } } }) + '\n'
t.deepEqual(computed, output)
})
test('render with support for NON_NULL lists', t => {
var input = fs
.readFileSync(path.resolve(__dirname, 'test/simple-input.json'))
.toString()
var output = fs
.readFileSync(path.resolve(__dirname, 'test/simple-output.dot'))
.toString()
var computed = graphqlviz.render(input, {}) + '\n'
t.deepEqual(computed, output)
})
test('render with support for mutationType', t => {
var input = fs
.readFileSync(path.resolve(__dirname, 'test/query-mutation-input.json'))
.toString()
var output = fs
.readFileSync(path.resolve(__dirname, 'test/query-mutation-output.dot'))
.toString()
var computed = graphqlviz.render(input, {}) + '\n'
t.deepEqual(computed, output)
})
test('render with support for interface, union, and enum types', t => {
var input = fs
.readFileSync(path.resolve(__dirname, 'test/complex-input.json'))
.toString()
var output = fs
.readFileSync(path.resolve(__dirname, 'test/complex-output.dot'))
.toString()
var computed = graphqlviz.render(input) + '\n'
t.deepEqual(computed, output)
})
test('render with theme options inverted', t => {
var input = fs
.readFileSync(path.resolve(__dirname, 'test/complex-input.json'))
.toString()
var output = fs
.readFileSync(path.resolve(__dirname, 'test/complex-output-all.dot'))
.toString()
var computed =
graphqlviz.render(input, {
theme: {
header: {
invert: true
},
anchor: {
header: true,
input: true
},
edgesToSelf: true,
field: {
align: 'LEFT',
hideSeperators: true,
colorArgs: true
},
edgeLabels: {
input: 'is an input to',
union: 'is union by',
interface: 'is implemented by'
},
types: {
color: 'RED4',
hide: false,
group: true,
groupLabel: 'Types',
stereotype: null
},
inputs: {
color: 'MIDNIGHTBLUE',
hide: false,
group: true,
groupLabel: 'Input Types',
stereotype: null
},
enums: {
color: 'LIMEGREEN',
hide: false,
group: true,
groupLabel: 'Enum Types',
stereotype: null
},
interfaces: {
color: 'ORANGERED',
hide: false,
group: true,
groupLabel: 'Interface Types',
stereotype: null
},
unions: {
color: 'DARKORCHID',
hide: false,
group: true,
groupLabel: 'Unions',
stereotype: null
}
}
}) + '\n'
t.deepEqual(computed, output)
})