Using Node, Sinon, and proxyquire.
I am trying to assert lock.normalAlert
boolean value.
I am not able to assert the correct value...I only get the initial stubbed value.
Is proxyquire able to inject objects or just modules? I wasn't sure if the issue was injection.
test:
sandbox = sinon.sandbox.create();
var lock = require('../alerts').lock;
sandbox.stub(lock, 'normalAlert', false);
var alerts = proxy('../alerts',
{'node-fetch': fetch,
'lock': lock
});
alerts.normalAlert('light', 1)
lock.normalAlert.should.be.true;
code:
function _setNormalAlertLockout() {
if (!lock.normalAlert) {
lock.normalAlert = true;
console.log(lock.normalAlert);
setTimeout(()=> {
lock.normalAlert = false;
}, NORMAL_ALERT_LOCKOUT_TIME);
}
}
module.exports = {
lock: lock
}
via dman
No comments:
Post a Comment