Skip to content

Instantly share code, notes, and snippets.

@bulkan
Created January 7, 2015 22:39

Revisions

  1. bulkan created this gist Jan 7, 2015.
    22 changes: 22 additions & 0 deletions user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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');
    })
    })
    })