1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const lodash_1 = require("../wrap/lodash");
|
4 | class Stubbing {
|
5 | constructor(type, args, outcomes, options = {}) {
|
6 | this.type = type;
|
7 | this.args = args;
|
8 | this.outcomes = outcomes;
|
9 | this.options = options;
|
10 | this.satisfyingCalls = new Set();
|
11 | }
|
12 | get hasTimesRemaining() {
|
13 | if (this.options.times == null)
|
14 | return true;
|
15 | return this.satisfyingCalls.size < this.options.times;
|
16 | }
|
17 | get currentOutcome() {
|
18 | const outcomeIndex = Math.max(0, this.satisfyingCalls.size - 1);
|
19 | if (outcomeIndex < this.outcomes.length) {
|
20 | return this.outcomes[outcomeIndex];
|
21 | }
|
22 | else {
|
23 | return lodash_1.default.last(this.outcomes);
|
24 | }
|
25 | }
|
26 | addSatisfyingCall(call) {
|
27 | this.satisfyingCalls.add(call);
|
28 | }
|
29 | }
|
30 | exports.default = Stubbing;
|