unmock-core
Version:
[][npmjs] [](https://circleci.com/gh/unmock/unmock-js) [](h
29 lines • 819 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const sinon_1 = require("sinon");
const decorate_1 = require("./decorate");
class CallTracker {
constructor() {
this.spy = CallTracker.buildSpy(this.spyFn.bind(this));
}
static buildSpy(gen) {
const bareSpy = sinon_1.spy(gen);
return decorate_1.default(bareSpy);
}
track({ req, res, }) {
this.returnValue = res;
this.spy(req);
this.returnValue = undefined;
}
reset() {
this.spy.resetHistory();
}
spyFn(_) {
if (typeof this.returnValue === "undefined") {
throw Error("Undefined return value");
}
return this.returnValue;
}
}
exports.createCallTracker = () => new CallTracker();
//# sourceMappingURL=index.js.map