diff --git a/package.json b/package.json index 23f62516..6801f41d 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,7 @@ "devDependencies": { "bluebird": "^2.9.9", "mocha": "^2.1.0", - "should": "^5.0.0", - "sinon": "^1.14.1" + "should": "^5.0.0" }, "dependencies": { "async": "^0.9.0", diff --git a/test/include.test.js b/test/include.test.js index 12c3050c..d513e215 100644 --- a/test/include.test.js +++ b/test/include.test.js @@ -1,6 +1,5 @@ // This test written in mocha+should.js var should = require('./init.js'); -var sinon = require('sinon'); var async = require('async'); var db, User, Profile, AccessToken, Post, Passport, City, Street, Building, Assembly, Part; @@ -382,12 +381,19 @@ describe('include', function () { }); }); - describe(' performance - ', function () { - beforeEach(function () { - this.callSpy = sinon.spy(db.connector, 'all'); + describe('performance', function () { + var all; + beforeEach(function() { + this.called = 0; + var self = this; + all = db.connector.all; + db.connector.all = function(model, filter, options, cb) { + self.called++; + return all.apply(db.connector, arguments); + }; }); - afterEach(function () { - db.connector.all.restore(); + afterEach(function() { + db.connector.all = all; }); it('including belongsTo should make only 2 db calls', function (done) { var self = this; @@ -407,7 +413,7 @@ describe('include', function () { owner.id.should.eql(p.ownerId); } }); - self.callSpy.calledTwice.should.be.true; + self.called.should.eql(2); done(); }); }); @@ -434,7 +440,7 @@ describe('include', function () { }); }, next); }, function (err) { - self.callSpy.reset(); + self.called = 0; Assembly.find({ where: { name: { @@ -452,7 +458,7 @@ describe('include', function () { result[1].parts().should.have.length(2); //SUV result[2].parts().should.have.length(0); - self.callSpy.calledThrice.should.be.true; + self.called.should.eql(3); done(); }); }); @@ -489,7 +495,7 @@ describe('include', function () { pp.ownerId.should.eql(user.id); }); }); - self.callSpy.calledThrice.should.be.true; + self.called.should.eql(3); done(); }); }); @@ -528,7 +534,7 @@ describe('include', function () { pp.ownerId.should.eql(user.id); }); }); - self.callSpy.calledThrice.should.be.true; + self.called.should.eql(3); done(); }); }); diff --git a/test/spec_helper.js b/test/spec_helper.js index 24b1ea6b..df3ac9d8 100644 --- a/test/spec_helper.js +++ b/test/spec_helper.js @@ -6,12 +6,6 @@ } */ -try { - global.sinon = require('sinon'); -} catch (e) { - // ignore -} - var group_name = false, EXT_EXP; function it(should, test_case) { check_external_exports();