@@ -42,12 +42,19 @@ describe(`doesQueryContain`, function() {
42
42
expect ( doesQueryContain ( document , types , 'Organization' ) ) . to . be . false
43
43
expect ( doesQueryContain ( document , types , 'User' ) ) . to . be . false
44
44
45
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 1 ] ) ) ) . to
46
- . be . true
47
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 1 , 2 ] ) ) )
45
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 1 ) )
48
46
. to . be . true
49
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 2 ] ) ) ) . to
50
- . be . false
47
+ expect (
48
+ doesQueryContain (
49
+ document ,
50
+ types ,
51
+ 'Device' ,
52
+ data ,
53
+ d => d . id === 1 || d . id === 2
54
+ )
55
+ ) . to . be . true
56
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 2 ) )
57
+ . to . be . false
51
58
} )
52
59
it ( `connection test` , function ( ) {
53
60
const document = gql `
@@ -74,14 +81,21 @@ describe(`doesQueryContain`, function() {
74
81
. false
75
82
expect ( doesQueryContain ( document , types , 'User' ) ) . to . be . false
76
83
77
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 1 ] ) ) ) . to
78
- . be . true
79
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 2 ] ) ) ) . to
80
- . be . true
81
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 1 , 2 ] ) ) )
84
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 1 ) )
85
+ . to . be . true
86
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 2 ) )
82
87
. to . be . true
83
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 3 ] ) ) ) . to
84
- . be . false
88
+ expect (
89
+ doesQueryContain (
90
+ document ,
91
+ types ,
92
+ 'Device' ,
93
+ data ,
94
+ d => d . id === 1 || d . id === 2
95
+ )
96
+ ) . to . be . true
97
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 3 ) )
98
+ . to . be . false
85
99
} )
86
100
it ( `more complex test` , function ( ) {
87
101
const document = gql `
@@ -133,27 +147,40 @@ describe(`doesQueryContain`, function() {
133
147
expect ( doesQueryContain ( document , types , 'User' ) ) . to . be . false
134
148
135
149
expect (
136
- doesQueryContain ( document , types , 'Organization' , data , new Set ( [ 1 ] ) )
150
+ doesQueryContain ( document , types , 'Organization' , data , d => d . id === 1 )
137
151
) . to . be . true
138
152
expect (
139
- doesQueryContain ( document , types , 'Organization' , data , new Set ( [ 1 , 2 ] ) )
153
+ doesQueryContain (
154
+ document ,
155
+ types ,
156
+ 'Organization' ,
157
+ data ,
158
+ d => d . id === 1 || d . id === 2
159
+ )
140
160
) . to . be . true
141
161
expect (
142
- doesQueryContain ( document , types , 'Organization' , data , new Set ( [ 3 ] ) )
162
+ doesQueryContain ( document , types , 'Organization' , data , d => d . id === 3 )
143
163
) . to . be . false
144
164
145
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 1 ] ) ) ) . to
146
- . be . true
147
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 2 ] ) ) ) . to
148
- . be . true
149
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 1 , 2 ] ) ) )
165
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 1 ) )
150
166
. to . be . true
151
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 3 ] ) ) ) . to
152
- . be . true
153
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 4 ] ) ) ) . to
154
- . be . true
155
- expect ( doesQueryContain ( document , types , 'Device' , data , new Set ( [ 5 ] ) ) ) . to
156
- . be . false
167
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 2 ) )
168
+ . to . be . true
169
+ expect (
170
+ doesQueryContain (
171
+ document ,
172
+ types ,
173
+ 'Device' ,
174
+ data ,
175
+ d => d . id === 1 || d . id === 2
176
+ )
177
+ ) . to . be . true
178
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 3 ) )
179
+ . to . be . true
180
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 4 ) )
181
+ . to . be . true
182
+ expect ( doesQueryContain ( document , types , 'Device' , data , d => d . id === 5 ) )
183
+ . to . be . false
157
184
} )
158
185
it ( `recursive type test` , function ( ) {
159
186
const document = gql `
@@ -187,8 +214,7 @@ describe(`doesQueryContain`, function() {
187
214
types ,
188
215
'MetadataItem' ,
189
216
data ,
190
- new Set ( [ 'foo' ] ) ,
191
- 'tag'
217
+ i => i . tag === 'foo'
192
218
)
193
219
) . to . be . true
194
220
expect (
@@ -197,8 +223,7 @@ describe(`doesQueryContain`, function() {
197
223
types ,
198
224
'MetadataItem' ,
199
225
data ,
200
- new Set ( [ 'foo' , 'foo/bar' ] ) ,
201
- 'tag'
226
+ i => i . tag === 'foo/bar'
202
227
)
203
228
) . to . be . true
204
229
expect (
@@ -207,18 +232,7 @@ describe(`doesQueryContain`, function() {
207
232
types ,
208
233
'MetadataItem' ,
209
234
data ,
210
- new Set ( [ 'foo/bar' ] ) ,
211
- 'tag'
212
- )
213
- ) . to . be . true
214
- expect (
215
- doesQueryContain (
216
- document ,
217
- types ,
218
- 'MetadataItem' ,
219
- data ,
220
- new Set ( [ 'foo/bar/baz' ] ) ,
221
- 'tag'
235
+ i => i . tag === 'foo/bar/baz'
222
236
)
223
237
) . to . be . false
224
238
} )
@@ -293,16 +307,19 @@ describe(`doesQueryContain`, function() {
293
307
}
294
308
295
309
expect (
296
- doesQueryContain ( document , types , 'Organization' , data , new Set ( [ 7 ] ) )
310
+ doesQueryContain ( document , types , 'Organization' , data , o => o . id === 7 )
311
+ ) . to . be . true
312
+ expect (
313
+ doesQueryContain ( document , types , 'Organization' , data , o => o . id === 5 )
297
314
) . to . be . true
298
315
expect (
299
- doesQueryContain ( document , types , 'Organization' , data , new Set ( [ 5 , 8 ] ) )
316
+ doesQueryContain ( document , types , 'Organization' , data , o => o . id === 8 )
300
317
) . to . be . true
301
318
expect (
302
- doesQueryContain ( document , types , 'Organization' , data , new Set ( [ 2 ] ) )
319
+ doesQueryContain ( document , types , 'Organization' , data , o => o . id === 2 )
303
320
) . to . be . true
304
321
expect (
305
- doesQueryContain ( document , types , 'Organization' , data , new Set ( [ 3 ] ) )
322
+ doesQueryContain ( document , types , 'Organization' , data , o => o . id === 3 )
306
323
) . to . be . false
307
324
} )
308
325
} )
0 commit comments