diff --git a/package.json b/package.json index ed083d0..62d0f21 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/express/index.spec.js b/src/express/index.spec.js index 8aec603..c565b46 100644 --- a/src/express/index.spec.js +++ b/src/express/index.spec.js @@ -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() { diff --git a/src/test-setup.spec.js b/src/test-setup.spec.js new file mode 100644 index 0000000..19165ca --- /dev/null +++ b/src/test-setup.spec.js @@ -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(); +});