jasmine-auto-spies
Version:
Create automatic spies from classes in jasmine tests, also for promises and observables
23 lines • 954 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFunctionSpy = void 0;
var auto_spies_core_1 = require("@hirez_io/auto-spies-core");
function createFunctionSpy(name) {
return (0, auto_spies_core_1.createFunctionAutoSpy)(name, addJasmineSyncMethodsToCalledWithObject, jasmineFunctionSpyFactory);
}
exports.createFunctionSpy = createFunctionSpy;
function jasmineFunctionSpyFactory(name, spyFunctionImpl) {
var functionSpy = jasmine.createSpy(name);
functionSpy.and.callFake(spyFunctionImpl);
return {
functionSpy: functionSpy,
objectToAddSpyMethodsTo: functionSpy.and,
};
}
function addJasmineSyncMethodsToCalledWithObject(calledWithObject, calledWithArgs) {
calledWithObject.returnValue = function (value) {
calledWithObject.argsToValuesMap.set(calledWithArgs, { value: value });
};
return calledWithObject;
}
//# sourceMappingURL=create-function-spy.js.map