Skip to content

Commit

Permalink
test(express): cover Express middleware schema creation with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gergelyke authored and Peter Marton committed Jul 27, 2015
1 parent 8dc7282 commit 348aac9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
"homepage": "https://github.com/RisingStack/graffiti#readme",
"devDependencies": {
"chai": "^3.2.0",
"chai-subset": "^1.0.1",
"eslint": "1.0.0-rc-3",
"express": "^4.13.1",
"mocha": "^2.2.5",
"pre-commit": "^1.0.10"
"pre-commit": "^1.0.10",
"sinon": "^1.15.4",
"sinon-chai": "^2.8.0"
},
"pre-commit": [
"eslint",
Expand Down
18 changes: 17 additions & 1 deletion src/express/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,23 @@ describe('graffiti express', function() {
});
});

it('creates the schema');
it('creates the schema', function() {

var getSchemaSpy = this.sandbox.spy();
var models = [{
name: 'User'
}];

var mw = express({
prefix: '/graphql',
models: models,
adapter: {
getSchema: getSchemaSpy
}
});

expect(getSchemaSpy).to.be.calledWith(models);
});

describe('requested url starts with prefix', function() {

Expand Down
17 changes: 17 additions & 0 deletions src/test-setup.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var sinon = require('sinon');
var chai = require('chai');
var sinonChai = require('sinon-chai');
var chaiSubset = require('chai-subset');

before(function() {
chai.use(chaiSubset);
chai.use(sinonChai);
});

beforeEach(function() {
this.sandbox = sinon.sandbox.create();
});

afterEach(function() {
this.sandbox.restore();
});

0 comments on commit 348aac9

Please sign in to comment.