Skip to content

Instantly share code, notes, and snippets.

@JakeDawkins
Created July 13, 2018 22:50
Show Gist options
  • Save JakeDawkins/66f5b026cf21515f1004f057754a2cd4 to your computer and use it in GitHub Desktop.
Save JakeDawkins/66f5b026cf21515f1004f057754a2cd4 to your computer and use it in GitHub Desktop.
testing default enum errors
const {
graphql,
GraphQLEnumType,
GraphQLType,
GraphQLSchema,
GraphQLObjectType,
GraphQLBoolean,
} = require('graphql');
const { gql } = require('graphql-tag');
const allowedColor = new GraphQLEnumType({
name: 'AllowedColor',
values: {
RED: { value: '#f00' },
GREEN: { value: '#0f0' },
BLUE: { value: '#00f' },
},
});
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: () => ({
avatar: {
type: GraphQLBoolean,
args: {
anEnum: {
type: allowedColor,
defaultValue: 'RED',
},
},
resolve: (root, args) => (args.anEnum === 'RED' ? false : true),
},
}),
}),
});
describe('Query', () => {
it('queries', () => {
const query = gql`
{
avatar
}
`;
const res = graphql(schema, query);
res.then(data => {
// this returns false right now
expect(data).toEqual({ data: { avatar: true } });
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment