UNPKG

offensive

Version:

Fast and boilerplate-free precondition checks for javascript.

40 lines (39 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LessThanAssertion = void 0; var model_1 = require("../../model"); var NoDsl_1 = require("../../NoDsl"); /** * @author Maciej Chałapuk (maciej@chalapuk.pl) */ var LessThanAssertion = /** @class */ (function () { function LessThanAssertion(comparedNumber) { this.comparedNumber = comparedNumber; } LessThanAssertion.prototype.assert = function (varName, testedValue) { var comparedNumber = this.comparedNumber; return { get success() { return testedValue < comparedNumber; }, get message() { return new model_1.StandardMessage(varName, "be < ".concat(comparedNumber), testedValue); }, }; }; return LessThanAssertion; }()); exports.LessThanAssertion = LessThanAssertion; (function (LessThanAssertion) { /** * @author Maciej Chałapuk (maciej@chalapuk.pl) */ function factory(args) { NoDsl_1.nodslArguments.check(args.length === 1, '.lessThan requires 1 argument (got ', args.length, ')'); NoDsl_1.nodslArguments.check(typeof args[0] === 'number', 'comparedNumber must be a number (got ', (typeof args[0]), ')'); return new LessThanAssertion(args[0]); } LessThanAssertion.factory = factory; })(LessThanAssertion = exports.LessThanAssertion || (exports.LessThanAssertion = {})); exports.LessThanAssertion = LessThanAssertion; exports.default = LessThanAssertion;