I'm using Mocha as test runner, Chai for assertion and Sinon. I'm having trouble using sinon, I have the following function that I want to test in PrestigeQuoteService.js file
find: function (criteria) {
return PrestigeQuote.find(criteria)
.populate('client')
.populate('vehicle')
.populate('quoteLogs');
},
and here is my test case
describe('find()', function () {
describe('prestige quote found', function () {
before(function () {
sandbox = sinon.sandbox.create();
var mockChain = {
populate: function () {
return this;
}
};
sandbox
.stub(PrestigeQuote, 'find').returns(mockChain);
});
it('should return a particular quote', function (done) {
PrestigeQuoteService.find({id: 1}, function (err, result) {
result.should.exist;
done();
});
});
after(function () {
sandbox.restore();
});
});
});
yet I get this error, even thought I have done() and should return value by default.
Error: timeout of 10000ms exceeded. Ensure the done() callback is being called in this test.
Aucun commentaire:
Enregistrer un commentaire