Skip to content

Instantly share code, notes, and snippets.

@ddialar
Created September 28, 2017 13:40
Show Gist options
  • Save ddialar/a3910eec9acaa9055e66080be3605def to your computer and use it in GitHub Desktop.
Save ddialar/a3910eec9acaa9055e66080be3605def to your computer and use it in GitHub Desktop.
import 'jest';
import * as graphql from 'graphql';
import UserType from '../../../src/graphql/models/user.type';
import * as PhoneNumberType from '../../../src/graphql/models/phone.number.type';
import * as EmailAddressType from '../../../src/graphql/models/email.address.type';
import TimestampType from '../../../src/graphql/custom-types/timestamp.type';
describe('Testing UserType ...', () => {
test('Fields integrity.', () => {
let userFields = UserType.getFields();
expect(userFields).toHaveProperty('_id');
expect(userFields._id.type).toMatchObject(graphql.GraphQLID);
expect(userFields).toHaveProperty('username');
expect(userFields.username.type).toMatchObject(graphql.GraphQLString);
expect(userFields).toHaveProperty('password');
expect(userFields.password.type).toMatchObject(graphql.GraphQLString);
expect(userFields).toHaveProperty('token');
expect(userFields.token.type).toMatchObject(graphql.GraphQLString);
expect(userFields).toHaveProperty('role');
expect(userFields.role.type).toMatchObject(graphql.GraphQLInt);
expect(userFields).toHaveProperty('name');
expect(userFields.name.type).toMatchObject(graphql.GraphQLString);
expect(userFields).toHaveProperty('surname');
expect(userFields.surname.type).toMatchObject(graphql.GraphQLString);
expect(userFields).toHaveProperty('phoneNumber');
expect(userFields.phoneNumber.type).toMatchObject(new graphql.GraphQLList(PhoneNumberType.ObjectType));
expect(userFields).toHaveProperty('emailAddress');
expect(userFields.emailAddress.type).toMatchObject(new graphql.GraphQLList(EmailAddressType.ObjectType));
expect(userFields).toHaveProperty('locale');
expect(userFields.locale.type).toMatchObject(graphql.GraphQLString);
expect(userFields).toHaveProperty('isEnabled');
expect(userFields.isEnabled.type).toMatchObject(graphql.GraphQLBoolean);
expect(userFields).toHaveProperty('lastLoginTimestamp');
expect(userFields.lastLoginTimestamp.type).toMatchObject(TimestampType);
expect(userFields).toHaveProperty('createdAt');
expect(userFields.createdAt.type).toMatchObject(TimestampType);
expect(userFields).toHaveProperty('createdBy');
expect(userFields.createdBy.type).toMatchObject(graphql.GraphQLID);
expect(userFields).toHaveProperty('updatedAt');
expect(userFields.updatedAt.type).toMatchObject(TimestampType);
expect(userFields).toHaveProperty('updatedBy');
expect(userFields.updatedBy.type).toMatchObject(graphql.GraphQLID);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment