File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -686,15 +686,19 @@ describe('Parser', () => {
686
686
687
687
it ( 'parses nullable types' , ( ) => {
688
688
const result = parseType ( 'MyType?' , { useSemanticNullability : true } ) ;
689
- expectJSON ( result ) . toDeepEqual ( {
690
- kind : Kind . NAMED_TYPE ,
691
- loc : { start : 0 , end : 6 } ,
692
- name : {
693
- kind : Kind . NAME ,
694
- loc : { start : 0 , end : 6 } ,
695
- value : 'MyType' ,
696
- } ,
697
- } ) ;
689
+ expectJSON ( result ) . toDeepEqual (
690
+ { kind : Kind . SEMANTIC_OPTIONAL_TYPE ,
691
+ loc : { start : 0 , end : 7 } ,
692
+ type : {
693
+ kind : Kind . NAMED_TYPE ,
694
+ loc : { start : 0 , end : 6 } ,
695
+ name : {
696
+ kind : Kind . NAME ,
697
+ loc : { start : 0 , end : 6 } ,
698
+ value : 'MyType' ,
699
+ } ,
700
+ }
701
+ } ) ;
698
702
} ) ;
699
703
700
704
it ( 'parses non-nullable types' , ( ) => {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { dedent } from '../../__testUtils__/dedent';
5
5
import { kitchenSinkSDL } from '../../__testUtils__/kitchenSinkSDL' ;
6
6
7
7
import { Kind } from '../kinds' ;
8
- import { parse } from '../parser' ;
8
+ import { parse , parseType } from '../parser' ;
9
9
import { print } from '../printer' ;
10
10
11
11
describe ( 'Printer: SDL document' , ( ) => {
@@ -180,4 +180,21 @@ describe('Printer: SDL document', () => {
180
180
}
181
181
` ) ;
182
182
} ) ;
183
+
184
+ it ( 'prints NamedType' , ( ) => {
185
+ expect ( print ( parseType ( 'MyType' , { useSemanticNullability : false } ) ) ) . to . equal ( dedent `MyType` ) ;
186
+ } ) ;
187
+
188
+ it ( 'prints SemanticOptionalType' , ( ) => {
189
+ expect ( print ( parseType ( 'MyType?' , { useSemanticNullability : true } ) ) ) . to . equal ( dedent `MyType?` ) ;
190
+ } ) ;
191
+
192
+ it ( 'prints SemanticNonNullType' , ( ) => {
193
+ expect ( print ( parseType ( 'MyType' , { useSemanticNullability : true } ) ) ) . to . equal ( dedent `MyType` ) ;
194
+ } ) ;
195
+
196
+ it ( 'prints NonNullType' , ( ) => {
197
+ expect ( print ( parseType ( 'MyType!' , { useSemanticNullability : true } ) ) ) . to . equal ( dedent `MyType!` ) ;
198
+ expect ( print ( parseType ( 'MyType!' , { useSemanticNullability : false } ) ) ) . to . equal ( dedent `MyType!` ) ;
199
+ } ) ;
183
200
} ) ;
You can’t perform that action at this time.
0 commit comments