UNPKG

unmock-core

Version:

[![npm](https://img.shields.io/npm/v/unmock-core.svg)][npmjs] [![CircleCI](https://circleci.com/gh/unmock/unmock-js.svg?style=svg)](https://circleci.com/gh/unmock/unmock-js) [![codecov](https://codecov.io/gh/unmock/unmock-js/branch/dev/graph/badge.svg)](h

29 lines 819 B
"use strict"; 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