@@ -612,6 +612,72 @@ describe('Type System Printer', () => {
612612 ` ) ;
613613 } ) ;
614614
615+ it ( 'One-line prints a short description' , ( ) => {
616+ const description = 'This field is awesome' ;
617+ const output = printSingleFieldSchema ( {
618+ type : GraphQLString ,
619+ description,
620+ } ) ;
621+ expect ( output ) . to . equal ( dedent `
622+ schema {
623+ query: Root
624+ }
625+
626+ type Root {
627+ """This field is awesome"""
628+ singleField: String
629+ }
630+ ` ) ;
631+ const recreatedRoot = buildSchema ( output ) . getTypeMap ( ) [ 'Root' ] ;
632+ const recreatedField = recreatedRoot . getFields ( ) [ 'singleField' ] ;
633+ expect ( recreatedField . description ) . to . equal ( description ) ;
634+ } ) ;
635+
636+ it ( 'Does not one-line print a description that ends with a quote' , ( ) => {
637+ const description = 'This field is "awesome"' ;
638+ const output = printSingleFieldSchema ( {
639+ type : GraphQLString ,
640+ description,
641+ } ) ;
642+ expect ( output ) . to . equal ( dedent `
643+ schema {
644+ query: Root
645+ }
646+
647+ type Root {
648+ """
649+ This field is "awesome"
650+ """
651+ singleField: String
652+ }
653+ ` ) ;
654+ const recreatedRoot = buildSchema ( output ) . getTypeMap ( ) [ 'Root' ] ;
655+ const recreatedField = recreatedRoot . getFields ( ) [ 'singleField' ] ;
656+ expect ( recreatedField . description ) . to . equal ( description ) ;
657+ } ) ;
658+
659+ it ( 'Preserves leading spaces when printing a description' , ( ) => {
660+ const description = ' This field is "awesome"' ;
661+ const output = printSingleFieldSchema ( {
662+ type : GraphQLString ,
663+ description,
664+ } ) ;
665+ expect ( output ) . to . equal ( dedent `
666+ schema {
667+ query: Root
668+ }
669+
670+ type Root {
671+ """ This field is "awesome"
672+ """
673+ singleField: String
674+ }
675+ ` ) ;
676+ const recreatedRoot = buildSchema ( output ) . getTypeMap ( ) [ 'Root' ] ;
677+ const recreatedField = recreatedRoot . getFields ( ) [ 'singleField' ] ;
678+ expect ( recreatedField . description ) . to . equal ( description ) ;
679+ } ) ;
680+
615681 it ( 'Print Introspection Schema' , ( ) => {
616682 const Root = new GraphQLObjectType ( {
617683 name : 'Root' ,
0 commit comments