119 lines
15 KiB
JavaScript
119 lines
15 KiB
JavaScript
|
"use strict";
|
||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.NotMatchAssertionCommand = exports.MatchAssertionCommand = exports.NotWithinAssertionCommand = exports.WithinAssertionCommand = exports.LteAssertionCommand = exports.LtAssertionCommand = exports.GteAssertionCommand = exports.GtAssertionCommand = exports.NotTypeOfAssertionCommand = exports.TypeOfAssertionCommand = exports.NotContainsAssertionCommand = exports.ContainsAssertionCommand = exports.NotOkAssertionCommand = exports.OkAssertionCommand = exports.NotEqlAssertionCommand = exports.EqlAssertionCommand = exports.AssertionCommand = void 0;
|
||
|
const type_1 = __importDefault(require("./type"));
|
||
|
const base_1 = require("./base");
|
||
|
const options_1 = require("./options");
|
||
|
const runtime_1 = require("../../errors/runtime");
|
||
|
const test_run_1 = require("../../errors/test-run");
|
||
|
const execute_js_expression_1 = require("../execute-js-expression");
|
||
|
const utils_1 = require("./utils");
|
||
|
const type_2 = __importDefault(require("../../assertions/type"));
|
||
|
const argument_1 = require("./validations/argument");
|
||
|
// Initializers
|
||
|
function initAssertionOptions(name, val) {
|
||
|
return new options_1.AssertionOptions(val, true);
|
||
|
}
|
||
|
//Initializers
|
||
|
function initAssertionParameter(name, val, { skipVisibilityCheck, testRun }) {
|
||
|
try {
|
||
|
if ((0, utils_1.isJSExpression)(val))
|
||
|
val = (0, execute_js_expression_1.executeJsExpression)(val.value, testRun, { skipVisibilityCheck });
|
||
|
return val;
|
||
|
}
|
||
|
catch (err) {
|
||
|
throw new test_run_1.AssertionExecutableArgumentError(name, val.value, err, err instanceof runtime_1.APIError);
|
||
|
}
|
||
|
}
|
||
|
const ASSERTION_NOT_REPORTED_PROPERTIES = ['id', 'originActual'];
|
||
|
// Commands
|
||
|
class AssertionCommand extends base_1.ActionCommandBase {
|
||
|
constructor(obj, testRun, validateProperties) {
|
||
|
super(obj, testRun, type_1.default.assertion, validateProperties);
|
||
|
}
|
||
|
getAssignableProperties() {
|
||
|
return [
|
||
|
{ name: 'id', type: argument_1.nonEmptyStringArgument, required: false },
|
||
|
{ name: 'assertionType', type: argument_1.nonEmptyStringArgument, required: true },
|
||
|
{ name: 'originActual', defaultValue: void 0 },
|
||
|
{ name: 'actual', init: initAssertionParameter, defaultValue: void 0 },
|
||
|
{ name: 'expected', init: initAssertionParameter, defaultValue: void 0 },
|
||
|
{ name: 'expected2', init: initAssertionParameter, defaultValue: void 0 },
|
||
|
{ name: 'message', type: argument_1.stringArgument, defaultValue: null },
|
||
|
{ name: 'options', type: argument_1.actionOptions, init: initAssertionOptions, required: true },
|
||
|
];
|
||
|
}
|
||
|
getNonReportedProperties() {
|
||
|
return super.getNonReportedProperties().concat(ASSERTION_NOT_REPORTED_PROPERTIES);
|
||
|
}
|
||
|
}
|
||
|
exports.AssertionCommand = AssertionCommand;
|
||
|
AssertionCommand.methodName = 'expect';
|
||
|
class EqlAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.EqlAssertionCommand = EqlAssertionCommand;
|
||
|
EqlAssertionCommand.methodName = type_2.default.eql;
|
||
|
class NotEqlAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.NotEqlAssertionCommand = NotEqlAssertionCommand;
|
||
|
NotEqlAssertionCommand.methodName = type_2.default.notEql;
|
||
|
class OkAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.OkAssertionCommand = OkAssertionCommand;
|
||
|
OkAssertionCommand.methodName = type_2.default.ok;
|
||
|
class NotOkAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.NotOkAssertionCommand = NotOkAssertionCommand;
|
||
|
NotOkAssertionCommand.methodName = type_2.default.notOk;
|
||
|
class ContainsAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.ContainsAssertionCommand = ContainsAssertionCommand;
|
||
|
ContainsAssertionCommand.methodName = type_2.default.contains;
|
||
|
class NotContainsAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.NotContainsAssertionCommand = NotContainsAssertionCommand;
|
||
|
NotContainsAssertionCommand.methodName = type_2.default.notContains;
|
||
|
class TypeOfAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.TypeOfAssertionCommand = TypeOfAssertionCommand;
|
||
|
TypeOfAssertionCommand.methodName = type_2.default.typeOf;
|
||
|
class NotTypeOfAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.NotTypeOfAssertionCommand = NotTypeOfAssertionCommand;
|
||
|
NotTypeOfAssertionCommand.methodName = type_2.default.notTypeOf;
|
||
|
class GtAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.GtAssertionCommand = GtAssertionCommand;
|
||
|
GtAssertionCommand.methodName = type_2.default.gt;
|
||
|
class GteAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.GteAssertionCommand = GteAssertionCommand;
|
||
|
GteAssertionCommand.methodName = type_2.default.gte;
|
||
|
class LtAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.LtAssertionCommand = LtAssertionCommand;
|
||
|
LtAssertionCommand.methodName = type_2.default.lt;
|
||
|
class LteAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.LteAssertionCommand = LteAssertionCommand;
|
||
|
LteAssertionCommand.methodName = type_2.default.lte;
|
||
|
class WithinAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.WithinAssertionCommand = WithinAssertionCommand;
|
||
|
WithinAssertionCommand.methodName = type_2.default.within;
|
||
|
class NotWithinAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.NotWithinAssertionCommand = NotWithinAssertionCommand;
|
||
|
NotWithinAssertionCommand.methodName = type_2.default.notWithin;
|
||
|
class MatchAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.MatchAssertionCommand = MatchAssertionCommand;
|
||
|
MatchAssertionCommand.methodName = type_2.default.match;
|
||
|
class NotMatchAssertionCommand extends AssertionCommand {
|
||
|
}
|
||
|
exports.NotMatchAssertionCommand = NotMatchAssertionCommand;
|
||
|
NotMatchAssertionCommand.methodName = type_2.default.notMatch;
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXJ0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3Rlc3QtcnVuL2NvbW1hbmRzL2Fzc2VydGlvbi5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSxrREFBMEI7QUFDMUIsaUNBQTJDO0FBQzNDLHVDQUE2QztBQUM3QyxrREFBZ0Q7QUFDaEQsb0RBQXlFO0FBQ3pFLG9FQUErRDtBQUMvRCxtQ0FBeUM7QUFDekMsaUVBQW1EO0FBRW5ELHFEQUlnQztBQUdoQyxlQUFlO0FBQ2YsU0FBUyxvQkFBb0IsQ0FBRSxJQUFJLEVBQUUsR0FBRztJQUNwQyxPQUFPLElBQUksMEJBQWdCLENBQUMsR0FBRyxFQUFFLElBQUksQ0FBQyxDQUFDO0FBQzNDLENBQUM7QUFFRCxjQUFjO0FBQ2QsU0FBUyxzQkFBc0IsQ0FBRSxJQUFJLEVBQUUsR0FBRyxFQUFFLEVBQUUsbUJBQW1CLEVBQUUsT0FBTyxFQUFFO0lBQ3hFLElBQUk7UUFDQSxJQUFJLElBQUEsc0JBQWMsRUFBQyxHQUFHLENBQUM7WUFDbkIsR0FBRyxHQUFHLElBQUEsMkNBQW1CLEVBQUMsR0FBRyxDQUFDLEtBQUssRUFBRSxPQUFPLEVBQUUsRUFBRSxtQkFBbUIsRUFBRSxDQUFDLENBQUM7UUFFM0UsT0FBTyxHQUFHLENBQUM7S0FDZDtJQUNELE9BQU8sR0FBRyxFQUFFO1FBQ1IsTUFBTSxJQUFJLDJDQUFnQyxDQUFDLElBQUksRUFBRSxHQUFHLENBQU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