@@ -545,6 +545,60 @@ describe('Type System Printer', () => {
545
545
` ) ;
546
546
} ) ;
547
547
548
+ it ( 'One-line prints a short description' , ( ) => {
549
+ const description = 'This field is awesome' ;
550
+ const output = printSingleFieldSchema ( {
551
+ type : GraphQLString ,
552
+ description,
553
+ } ) ;
554
+ expect ( output ) . to . equal ( dedent `
555
+ type Query {
556
+ """This field is awesome"""
557
+ singleField: String
558
+ }
559
+ ` ) ;
560
+ const recreatedRoot = buildSchema ( output ) . getTypeMap ( ) [ 'Query' ] ;
561
+ const recreatedField = recreatedRoot . getFields ( ) [ 'singleField' ] ;
562
+ expect ( recreatedField . description ) . to . equal ( description ) ;
563
+ } ) ;
564
+
565
+ it ( 'Does not one-line print a description that ends with a quote' , ( ) => {
566
+ const description = 'This field is "awesome"' ;
567
+ const output = printSingleFieldSchema ( {
568
+ type : GraphQLString ,
569
+ description,
570
+ } ) ;
571
+ expect ( output ) . to . equal ( dedent `
572
+ type Query {
573
+ """
574
+ This field is "awesome"
575
+ """
576
+ singleField: String
577
+ }
578
+ ` ) ;
579
+ const recreatedRoot = buildSchema ( output ) . getTypeMap ( ) [ 'Query' ] ;
580
+ const recreatedField = recreatedRoot . getFields ( ) [ 'singleField' ] ;
581
+ expect ( recreatedField . description ) . to . equal ( description ) ;
582
+ } ) ;
583
+
584
+ it ( 'Preserves leading spaces when printing a description' , ( ) => {
585
+ const description = ' This field is "awesome"' ;
586
+ const output = printSingleFieldSchema ( {
587
+ type : GraphQLString ,
588
+ description,
589
+ } ) ;
590
+ expect ( output ) . to . equal ( dedent `
591
+ type Query {
592
+ """ This field is "awesome"
593
+ """
594
+ singleField: String
595
+ }
596
+ ` ) ;
597
+ const recreatedRoot = buildSchema ( output ) . getTypeMap ( ) [ 'Query' ] ;
598
+ const recreatedField = recreatedRoot . getFields ( ) [ 'singleField' ] ;
599
+ expect ( recreatedField . description ) . to . equal ( description ) ;
600
+ } ) ;
601
+
548
602
it ( 'Print Introspection Schema' , ( ) => {
549
603
const Query = new GraphQLObjectType ( {
550
604
name : 'Query' ,
0 commit comments