Skip to content

Commit

Permalink
Update double-quote schema printing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sethtippetts committed Jan 29, 2018
1 parent c7a1a59 commit 0e33b33
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/utilities/__tests__/schemaPrinter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import {
} from '../../';
import { GraphQLDirective } from '../../type/directives';
import { DirectiveLocation } from '../../language/directiveLocation';
import { parse } from '../../language/parser';
import { GraphQLError } from '../../error/GraphQLError';

function printForTest(schema) {
const schemaText = printSchema(schema);
Expand Down Expand Up @@ -851,19 +849,31 @@ describe('Type System Printer', () => {
`;
expect(output).to.equal(introspectionSchema);
});
it('Prints a parseable schema when a comment ends with a doublequote (")', () => {
const Root = new GraphQLObjectType({
name: 'Root',
fields: {
onlyField: {
type: GraphQLString,
description: 'This field is "awesome"',
},
},
it('Prints a field description that ends with a doublequote (")s', () => {
const description = 'This field is "awesome"';
const output = printSingleFieldSchema({
type: GraphQLString,
description,
});
const Schema = new GraphQLSchema({ query: Root });
const output = printSchema(Schema);
expect(() => parse(output)).not.to.throw(GraphQLError);
expect(output).to.equal(dedent`
schema {
query: Root
}
type Root {
"""This field is "awesome" """
singleField: String
}
`);
const recreatedRoot = buildSchema(output).getTypeMap()['Root'];
const recreatedField = recreatedRoot.getFields()['singleField'];

/* Note: Additional space added to prevent parser from confusing trailing double
* quote inside description with the end of the block string. It shouldn't
* affect result since descriptions are interpreted as Markdown so trailing
* spaces are ignored.
*/
expect(recreatedField.description).to.equal(description + ' ');
});
it('Print Introspection Schema with comment descriptions', () => {
const Query = new GraphQLObjectType({
Expand Down

0 comments on commit 0e33b33

Please sign in to comment.