-
-
Save parkerproject/782eeda0a5aef149808cb4a103298219 to your computer and use it in GitHub Desktop.
Mocking Sequelize model function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'); | |
var sinon = require('sinon'); | |
var User = require('./db/models').User; | |
describe('User model', function(){ | |
var userFindStub; | |
var sandbox; | |
before(function(){ | |
sandbox = sinon.sandbox.create(); | |
userFindStub = sanbox.stub(User, 'find'); | |
}) | |
it('should catch', function(){ | |
userFindStub.returns(Promise.reject(new Error('test-error'))) | |
return User.find({}) | |
.catch(function(err){ | |
should.exist(err); | |
err.message.should.equal('test-error'); | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment