@@ -457,6 +457,58 @@ type Hello {
457
457
expect ( printJson ( doc ) ) . to . equal ( printJson ( expected ) ) ;
458
458
} ) ;
459
459
460
+ it ( 'Union with two types and leading vertical bar' , ( ) => {
461
+ const body = 'union Hello = | Wo | Rld' ;
462
+ const doc = parse ( body ) ;
463
+ const expected = {
464
+ kind : 'Document' ,
465
+ definitions : [
466
+ {
467
+ kind : 'UnionTypeDefinition' ,
468
+ name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
469
+ directives : [ ] ,
470
+ types : [
471
+ typeNode ( 'Wo' , { start : 16 , end : 18 } ) ,
472
+ typeNode ( 'Rld' , { start : 21 , end : 24 } ) ,
473
+ ] ,
474
+ loc : { start : 0 , end : 24 } ,
475
+ }
476
+ ] ,
477
+ loc : { start : 0 , end : 24 } ,
478
+ } ;
479
+ expect ( printJson ( doc ) ) . to . equal ( printJson ( expected ) ) ;
480
+ } ) ;
481
+
482
+ it ( 'Union with no types and leading vertical bar' , ( ) => {
483
+ const body = 'union Hello = |' ;
484
+ expect ( ( ) => parse ( body ) ) . to . throw ( ) ;
485
+ } ) ;
486
+
487
+ it ( 'Union with types and ending vertical bar' , ( ) => {
488
+ const body = 'union Hello = Wo | Rld |' ;
489
+ expect ( ( ) => parse ( body ) ) . to . throw ( ) ;
490
+ } ) ;
491
+
492
+ it ( 'Union with types and double vertical bar at the beginning' , ( ) => {
493
+ const body = 'union Hello = || Wo | Rld' ;
494
+ expect ( ( ) => parse ( body ) ) . to . throw ( ) ;
495
+ } ) ;
496
+
497
+ it ( 'Union with types and double vertical bar in the middle' , ( ) => {
498
+ const body = 'union Hello = Wo || Rld' ;
499
+ expect ( ( ) => parse ( body ) ) . to . throw ( ) ;
500
+ } ) ;
501
+
502
+ it ( 'Union with types and double vertical bar at the end' , ( ) => {
503
+ const body = 'union Hello = | Wo | Rld ||' ;
504
+ expect ( ( ) => parse ( body ) ) . to . throw ( ) ;
505
+ } ) ;
506
+
507
+ it ( 'Union with types , leanding and ending vertical bar' , ( ) => {
508
+ const body = 'union Hello = | Wo | Rld |' ;
509
+ expect ( ( ) => parse ( body ) ) . to . throw ( ) ;
510
+ } ) ;
511
+
460
512
it ( 'Union with two types' , ( ) => {
461
513
const body = 'union Hello = Wo | Rld' ;
462
514
const doc = parse ( body ) ;
0 commit comments