chai-callslike
Version:
A simple sinon-chai assertion to validate many aspects of stub calls
18 lines (17 loc) • 791 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAssertFunction = void 0;
const check_call_count_1 = require("./check-call-count");
const check_calls_errors_1 = require("./check-calls-errors");
const colors_1 = require("./colors");
function getAssertFunction(_chai, utils, compareFunc) {
return function fn(...expectedCalls) {
const actualCalls = utils.flag(this, 'object');
let errors = check_call_count_1.checkCallCount(actualCalls, expectedCalls);
errors += check_calls_errors_1.checkCallsErrors(actualCalls, expectedCalls, compareFunc);
if (errors) {
_chai.assert.fail(colors_1.info(`On ${colors_1.ids(actualCalls.name)}${errors}`));
}
};
}
exports.getAssertFunction = getAssertFunction;