I am attempting to test geocode.js which has only one function :
// geocode.js
const googleApiClient = require('@google/maps').createClient({
key: CONFIG.googleApis.key
});
const poll = zipcode => {
return new Promise((resolve, reject) => {
googleApiClient.geocode({
address: zipcode
}, function(result) {
resolve(result);
});
});
};
module.exports = {poll}
so i have setup my mocha environment and installed sinon. I can't figure out how to stub the googleApiClient functionality.
I don't actually want to make any kind of external call during the test.
//geocode.spec.js
describe('geocode', function(){
before(function(){
//HOW DO I STUB googleApiClient ?
sinon.stub ...
})
});
via Bubble Trouble
No comments:
Post a Comment