Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eapache committed Apr 2, 2018
1 parent 3948be9 commit 9dd09cd
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/utilities/__tests__/findDescriptionChanges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,37 @@ describe('findDescriptionChanges', () => {
expect(findDescriptionChanges(newSchema, newSchema)).to.eql([]);
});

it('should detect if a description was changed on a type', () => {
const typeOld = new GraphQLObjectType({
name: 'Type',
description: 'Something rather',
fields: {
field1: { type: GraphQLString },
},
});
const typeNew = new GraphQLObjectType({
name: 'Type',
description: 'Something else',
fields: {
field1: { type: GraphQLString },
},
});

const oldSchema = new GraphQLSchema({
query: queryType,
types: [typeOld],
});
const newSchema = new GraphQLSchema({
query: queryType,
types: [typeNew],
});
expect(findDescriptionChanges(oldSchema, newSchema)[0].description).to.eql(
'Description changed on TYPE Type.',
);
expect(findDescriptionChanges(oldSchema, oldSchema)).to.eql([]);
expect(findDescriptionChanges(newSchema, newSchema)).to.eql([]);
});

it('should detect if a type with a description was added', () => {
const type = new GraphQLObjectType({
name: 'Type',
Expand All @@ -73,4 +104,37 @@ describe('findDescriptionChanges', () => {
expect(findDescriptionChanges(oldSchema, oldSchema)).to.eql([]);
expect(findDescriptionChanges(newSchema, newSchema)).to.eql([]);
});

it('should detect if a field with a description was added', () => {
const typeOld = new GraphQLObjectType({
name: 'Type',
fields: {
field1: { type: GraphQLString },
},
});
const typeNew = new GraphQLObjectType({
name: 'Type',
fields: {
field1: { type: GraphQLString },
field2: {
type: GraphQLString,
description: 'Something rather',
},
},
});

const oldSchema = new GraphQLSchema({
query: queryType,
types: [typeOld],
});
const newSchema = new GraphQLSchema({
query: queryType,
types: [typeNew],
});
expect(findDescriptionChanges(oldSchema, newSchema)[0].description).to.eql(
'New FIELD field2 added with description.',
);
expect(findDescriptionChanges(oldSchema, oldSchema)).to.eql([]);
expect(findDescriptionChanges(newSchema, newSchema)).to.eql([]);
});
});

0 comments on commit 9dd09cd

Please sign in to comment.