safe-mock
Version:
Type Safe Mocking Library written for Typescript and Javascript
35 lines (34 loc) • 1.6 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
function prettyPrintOtherInteractions(expectedCalls) {
return expectedCalls
.map(function (invocation) { return invocation.prettyPrint(); })
.join(",");
}
var CallsDontMatchError = /** @class */ (function (_super) {
__extends(CallsDontMatchError, _super);
function CallsDontMatchError(expectedCall, otherInteractions, methodName) {
var _this = _super.call(this) || this;
var message = methodName + " was not called with: " + expectedCall.prettyPrint() + "\n";
if (otherInteractions.length !== 0) {
message = message + (" Other interactions with this mock: [" + prettyPrintOtherInteractions(otherInteractions) + "]");
}
_this = _super.call(this, message) || this;
_this.showDiff = true;
_this.expected = expectedCall.args;
_this.actual = otherInteractions.map(function (interactions) { return interactions.args; });
return _this;
}
return CallsDontMatchError;
}(Error));
exports.default = CallsDontMatchError;