Skip to content

Commit

Permalink
test(query): cover with unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Marton committed Jul 30, 2015
1 parent 7b5ea46 commit d4635eb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ from 'graphql/type';
import {getProjection} from './projection';

/**
* TODO: return with field name
*
* @method getField
* @param {Object} field
* @param {Object} types
Expand Down
53 changes: 50 additions & 3 deletions src/query.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
import {expect} from 'chai';
import {
GraphQLString,
GraphQLFloat
} from 'graphql/type';

import {getArgs, getRootFields} from './query';
import {getModels} from './model';
import {getTypes} from './type';
import User from '../fixture/user';

describe('query', () => {
it('should get args properly');
it('should get singular root field properly');
it('should get plural root field properly');
let models;
let types;

before(() => {
models = getModels([User]);
types = getTypes(models);
});

it('should get args properly', () => {
let args = getArgs(types, models);

expect(args).to.be.eql({
User: {
_id: {
name: '_id',
type: GraphQLString
},
age: {
type: GraphQLFloat
}
}
});
});

it('should get root field properly', () => {
let rootFields = getRootFields(types, models);

expect(rootFields).to.containSubset({
user: {
args: {
_id: {},
age: {}
}
},
users: {
args: {
_id: {},
age: {}
}
}
});
});
});

0 comments on commit d4635eb

Please sign in to comment.