@@ -255,60 +255,89 @@ describe('Type predicates', () => {
255
255
} ) ;
256
256
257
257
describe ( 'isInputType' , ( ) => {
258
+ function expectInputType ( type ) {
259
+ expect ( isInputType ( type ) ) . to . equal ( true ) ;
260
+ expect ( ( ) => assertInputType ( type ) ) . not . to . throw ( ) ;
261
+ }
262
+
258
263
it ( 'returns true for an input type' , ( ) => {
259
- expect ( isInputType ( InputObjectType ) ) . to . equal ( true ) ;
260
- expect ( ( ) => assertInputType ( InputObjectType ) ) . not . to . throw ( ) ;
264
+ expectInputType ( GraphQLString ) ;
265
+ expectInputType ( EnumType ) ;
266
+ expectInputType ( InputObjectType ) ;
261
267
} ) ;
262
268
263
269
it ( 'returns true for a wrapped input type' , ( ) => {
264
- expect ( isInputType ( GraphQLList ( InputObjectType ) ) ) . to . equal ( true ) ;
265
- expect ( ( ) =>
266
- assertInputType ( GraphQLList ( InputObjectType ) ) ,
267
- ) . not . to . throw ( ) ;
268
- expect ( isInputType ( GraphQLNonNull ( InputObjectType ) ) ) . to . equal ( true ) ;
269
- expect ( ( ) =>
270
- assertInputType ( GraphQLNonNull ( InputObjectType ) ) ,
271
- ) . not . to . throw ( ) ;
270
+ expectInputType ( GraphQLList ( GraphQLString ) ) ;
271
+ expectInputType ( GraphQLList ( EnumType ) ) ;
272
+ expectInputType ( GraphQLList ( InputObjectType ) ) ;
273
+
274
+ expectInputType ( GraphQLNonNull ( GraphQLString ) ) ;
275
+ expectInputType ( GraphQLNonNull ( EnumType ) ) ;
276
+ expectInputType ( GraphQLNonNull ( InputObjectType ) ) ;
272
277
} ) ;
273
278
279
+ function expectNonInputType ( type ) {
280
+ expect ( isInputType ( type ) ) . to . equal ( false ) ;
281
+ expect ( ( ) => assertInputType ( type ) ) . to . throw ( ) ;
282
+ }
283
+
274
284
it ( 'returns false for an output type' , ( ) => {
275
- expect ( isInputType ( ObjectType ) ) . to . equal ( false ) ;
276
- expect ( ( ) => assertInputType ( ObjectType ) ) . to . throw ( ) ;
285
+ expectNonInputType ( ObjectType ) ;
286
+ expectNonInputType ( InterfaceType ) ;
287
+ expectNonInputType ( UnionType ) ;
277
288
} ) ;
278
289
279
290
it ( 'returns false for a wrapped output type' , ( ) => {
280
- expect ( isInputType ( GraphQLList ( ObjectType ) ) ) . to . equal ( false ) ;
281
- expect ( ( ) => assertInputType ( GraphQLList ( ObjectType ) ) ) . to . throw ( ) ;
282
- expect ( isInputType ( GraphQLNonNull ( ObjectType ) ) ) . to . equal ( false ) ;
283
- expect ( ( ) => assertInputType ( GraphQLNonNull ( ObjectType ) ) ) . to . throw ( ) ;
291
+ expectNonInputType ( GraphQLList ( ObjectType ) ) ;
292
+ expectNonInputType ( GraphQLList ( InterfaceType ) ) ;
293
+ expectNonInputType ( GraphQLList ( UnionType ) ) ;
294
+
295
+ expectNonInputType ( GraphQLNonNull ( ObjectType ) ) ;
296
+ expectNonInputType ( GraphQLNonNull ( InterfaceType ) ) ;
297
+ expectNonInputType ( GraphQLNonNull ( UnionType ) ) ;
284
298
} ) ;
285
299
} ) ;
286
300
287
301
describe ( 'isOutputType' , ( ) => {
302
+ function expectOutputType ( type ) {
303
+ expect ( isOutputType ( type ) ) . to . equal ( true ) ;
304
+ expect ( ( ) => assertOutputType ( type ) ) . not . to . throw ( ) ;
305
+ }
306
+
288
307
it ( 'returns true for an output type' , ( ) => {
289
- expect ( isOutputType ( ObjectType ) ) . to . equal ( true ) ;
290
- expect ( ( ) => assertOutputType ( ObjectType ) ) . not . to . throw ( ) ;
308
+ expectOutputType ( GraphQLString ) ;
309
+ expectOutputType ( ObjectType ) ;
310
+ expectOutputType ( InterfaceType ) ;
311
+ expectOutputType ( UnionType ) ;
312
+ expectOutputType ( EnumType ) ;
291
313
} ) ;
292
314
293
315
it ( 'returns true for a wrapped output type' , ( ) => {
294
- expect ( isOutputType ( GraphQLList ( ObjectType ) ) ) . to . equal ( true ) ;
295
- expect ( ( ) => assertOutputType ( GraphQLList ( ObjectType ) ) ) . not . to . throw ( ) ;
296
- expect ( isOutputType ( GraphQLNonNull ( ObjectType ) ) ) . to . equal ( true ) ;
297
- expect ( ( ) => assertOutputType ( GraphQLNonNull ( ObjectType ) ) ) . not . to . throw ( ) ;
316
+ expectOutputType ( GraphQLList ( GraphQLString ) ) ;
317
+ expectOutputType ( GraphQLList ( ObjectType ) ) ;
318
+ expectOutputType ( GraphQLList ( InterfaceType ) ) ;
319
+ expectOutputType ( GraphQLList ( UnionType ) ) ;
320
+ expectOutputType ( GraphQLList ( EnumType ) ) ;
321
+
322
+ expectOutputType ( GraphQLNonNull ( GraphQLString ) ) ;
323
+ expectOutputType ( GraphQLNonNull ( ObjectType ) ) ;
324
+ expectOutputType ( GraphQLNonNull ( InterfaceType ) ) ;
325
+ expectOutputType ( GraphQLNonNull ( UnionType ) ) ;
326
+ expectOutputType ( GraphQLNonNull ( EnumType ) ) ;
298
327
} ) ;
299
328
329
+ function expectNonOutputType ( type ) {
330
+ expect ( isOutputType ( type ) ) . to . equal ( false ) ;
331
+ expect ( ( ) => assertOutputType ( type ) ) . to . throw ( ) ;
332
+ }
333
+
300
334
it ( 'returns false for an input type' , ( ) => {
301
- expect ( isOutputType ( InputObjectType ) ) . to . equal ( false ) ;
302
- expect ( ( ) => assertOutputType ( InputObjectType ) ) . to . throw ( ) ;
335
+ expectNonOutputType ( InputObjectType ) ;
303
336
} ) ;
304
337
305
338
it ( 'returns false for a wrapped input type' , ( ) => {
306
- expect ( isOutputType ( GraphQLList ( InputObjectType ) ) ) . to . equal ( false ) ;
307
- expect ( ( ) => assertOutputType ( GraphQLList ( InputObjectType ) ) ) . to . throw ( ) ;
308
- expect ( isOutputType ( GraphQLNonNull ( InputObjectType ) ) ) . to . equal ( false ) ;
309
- expect ( ( ) =>
310
- assertOutputType ( GraphQLNonNull ( InputObjectType ) ) ,
311
- ) . to . throw ( ) ;
339
+ expectNonOutputType ( GraphQLList ( InputObjectType ) ) ;
340
+ expectNonOutputType ( GraphQLNonNull ( InputObjectType ) ) ;
312
341
} ) ;
313
342
} ) ;
314
343
0 commit comments