must-call
Version:
example.on('end', mustCall(() => {})); Check the callback function is called.
21 lines (16 loc) • 460 B
JavaScript
const mustCall = require('../..');
const assert = require('assert');
const fixture = require('../fixture');
fixture.callCb(mustCall(() => {
assert.ok('passed');
}));
process.on('uncaughtException', (e) => {
assert(e.message === 'Mismatched <anonymous> function calls. Expected 1, actual 0.');
});
fixture.dntCallCb(mustCall(() => {
// not called here
assert.fail('failure');
}));
fixture.callCbTwice(mustCall(() => {
assert.ok('passed');
}, 2));