Skip to content

Commit

Permalink
Include test that printSchema includes non-spec directives. Closes #1072
Browse files Browse the repository at this point in the history
  • Loading branch information
leebyron committed Dec 7, 2017
1 parent a56e6ab commit 007407d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/utilities/__tests__/schemaPrinter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
GraphQLList,
GraphQLNonNull,
} from '../../';
import { GraphQLDirective } from '../../type/directives';
import { DirectiveLocation } from '../../language/directiveLocation';

function printForTest(schema) {
return printSchema(schema);
Expand Down Expand Up @@ -564,6 +566,33 @@ describe('Type System Printer', () => {
`);
});

it('Prints custom directives', () => {
const Query = new GraphQLObjectType({
name: 'Query',
fields: {
field: { type: GraphQLString },
},
});

const CustomDirective = new GraphQLDirective({
name: 'customDirective',
locations: [DirectiveLocation.FIELD],
});

const Schema = new GraphQLSchema({
query: Query,
directives: [CustomDirective],
});
const output = printForTest(Schema);
expect(output).to.equal(dedent`
directive @customDirective on FIELD
type Query {
field: String
}
`);
});

it('Print Introspection Schema', () => {
const Root = new GraphQLObjectType({
name: 'Root',
Expand Down

0 comments on commit 007407d

Please sign in to comment.