safe-mock
Version:
Type Safe Mocking Library written for Typescript and Javascript
27 lines (26 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var WhyNoReturnValueMatched = /** @class */ (function () {
function WhyNoReturnValueMatched(args, stubbedActionMatchers, propertyKey) {
this.args = args;
this.stubbedActionMatchers = stubbedActionMatchers;
this.propertyKey = propertyKey;
}
WhyNoReturnValueMatched.prototype.reasonAndAdvice = function () {
if (this.wereReturnValuesSet()) {
var stubbedArgs = this.argsForExisitingReturnValues();
return this.propertyKey.toString() + " was stubbed to return a value when called with " + stubbedArgs + " but was called with: " + this.args.prettyPrint();
}
return this.propertyKey.toString() + " has not been mocked yet. Set a mock return value for it.";
};
WhyNoReturnValueMatched.prototype.argsForExisitingReturnValues = function () {
return this.stubbedActionMatchers
.map(function (arg) { return arg.printArgs(); })
.join(' or ');
};
WhyNoReturnValueMatched.prototype.wereReturnValuesSet = function () {
return this.stubbedActionMatchers.length !== 0;
};
return WhyNoReturnValueMatched;
}());
exports.default = WhyNoReturnValueMatched;