История изменений
Исправление neversleep, (текущая версия) :
const proxyquire = require('proxyquire');
const { assert } = require('chai');
const Sinon = require('sinon');
describe('sum', () => {
it('sums two numbers', () => {
const fakeLogger = {
log: Sinon.stub(),
};
const sum = proxyquire('../src/sum', {
'./mylogger': {
log: fakeLogger.log,
}
}).sum;
assert.equal(sum(1, 2), 3);
assert(fakeLogger.log.calledOnce);
});
});
Исходная версия neversleep, :
[code] const proxyquire = require(‘proxyquire’); const { assert } = require(‘chai’); const Sinon = require(‘sinon’);
describe(‘sum’, () => { it(‘sums two numbers’, () => { const fakeLogger = { log: Sinon.stub(), };
const sum = proxyquire('../src/sum', {
'./mylogger': {
log: fakeLogger.log,
}
}).sum;
assert.equal(sum(1, 2), 3);
assert(fakeLogger.log.calledOnce);
}); }); [/code]