-
-
Save phishy/e135bdddeaf176bd5a71 to your computer and use it in GitHub Desktop.
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
module.exports = { | |
process: function() { | |
Vendor.find().then(function(res){ | |
console.log('success'); | |
}).catch(function(err){ | |
console.log('failure'); | |
}); | |
} | |
} |
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 assert = require('assert'); | |
var sinon = require('sinon'); | |
require('sinon-as-promised')(Promise); | |
var rewire = require('rewire'); | |
var Product = rewire('product.js'); | |
var vendorStub = {}; | |
Product.__set__({ Vendor: vendorStub }); | |
describe(function(){ | |
it('should stub Vendor even though Vendor isnt defined with var', function(done){ | |
vendorStub.find = sinon.stub().resolves(true); | |
Product.process().then(function(res){ | |
assert.ok(res); | |
}).catch(function(err){ | |
done(err); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment