Innovenergy_trunk/frontend/node_modules/testcafe/lib/api/test-controller/assertion.js

107 lines
21 KiB
JavaScript
Raw Normal View History

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assertion_1 = require("../../test-run/commands/assertion");
const test_run_1 = require("../../errors/test-run");
const types_1 = require("../../client-functions/types");
const add_rendered_warning_1 = __importDefault(require("../../notifications/add-rendered-warning"));
const warning_message_1 = __importDefault(require("../../notifications/warning-message"));
class Assertion {
constructor(actual, testController, callsite) {
this._testController = testController;
this._actual = actual;
this._callsite = callsite;
}
then() {
throw new test_run_1.AssertionWithoutMethodCallError(this._callsite);
}
_enqueueAssertion(command, assertionArgs) {
let options = assertionArgs.opts || {};
let message = assertionArgs.message;
// NOTE: Assertion options should be specified after the 'message' parameter.
// await t.expect(42).eql(43, 'wrong value', { timeout: 10000 });
// In case of empty assertion message we allowing to specify assertion option in place of assertion message.
// await t.expect(42).eql(43, { timeout: 10000 });
if (typeof message === 'object') {
options = assertionArgs.message;
message = void 0;
}
return this._testController.enqueueCommand(command, {
assertionType: command.methodName,
actual: this._actual,
expected: assertionArgs.expected,
expected2: assertionArgs.expected2,
message: message,
options: { timeout: options.timeout, allowUnawaitedPromise: options.allowUnawaitedPromise },
}, this._checkForWarnings.bind(this));
}
_checkForWarnings(testController, assertionCommand, callsite) {
testController.checkForExcessiveAwaits(callsite, assertionCommand);
if ((0, types_1.isClientFunction)(assertionCommand.actual)) {
(0, add_rendered_warning_1.default)(testController.warningLog, {
message: warning_message_1.default.assertedClientFunctionInstance,
actionId: assertionCommand.actionId,
}, callsite);
}
else if ((0, types_1.isSelector)(assertionCommand.actual)) {
(0, add_rendered_warning_1.default)(testController.warningLog, {
message: warning_message_1.default.assertedSelectorInstance,
actionId: assertionCommand.actionId,
}, callsite);
}
}
[assertion_1.EqlAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.EqlAssertionCommand, { expected, message, opts });
}
[assertion_1.NotEqlAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.NotEqlAssertionCommand, { expected, message, opts });
}
[assertion_1.OkAssertionCommand.methodName](message, opts) {
return this._enqueueAssertion(assertion_1.OkAssertionCommand, { message, opts });
}
[assertion_1.NotOkAssertionCommand.methodName](message, opts) {
return this._enqueueAssertion(assertion_1.NotOkAssertionCommand, { message, opts });
}
[assertion_1.ContainsAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.ContainsAssertionCommand, { expected, message, opts });
}
[assertion_1.NotContainsAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.NotContainsAssertionCommand, { expected, message, opts });
}
[assertion_1.TypeOfAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.TypeOfAssertionCommand, { expected, message, opts });
}
[assertion_1.NotTypeOfAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.NotTypeOfAssertionCommand, { expected, message, opts });
}
[assertion_1.GtAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.GtAssertionCommand, { expected, message, opts });
}
[assertion_1.GteAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.GteAssertionCommand, { expected, message, opts });
}
[assertion_1.LtAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.LtAssertionCommand, { expected, message, opts });
}
[assertion_1.LteAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.LteAssertionCommand, { expected, message, opts });
}
[assertion_1.WithinAssertionCommand.methodName](start, finish, message, opts) {
// NOTE: `within` is not available in Chai `assert` interface.
return this._enqueueAssertion(assertion_1.WithinAssertionCommand, { expected: start, expected2: finish, message, opts });
}
[assertion_1.NotWithinAssertionCommand.methodName](start, finish, message, opts) {
return this._enqueueAssertion(assertion_1.NotWithinAssertionCommand, { expected: start, expected2: finish, message, opts });
}
[assertion_1.MatchAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.MatchAssertionCommand, { expected, message, opts });
}
[assertion_1.NotMatchAssertionCommand.methodName](expected, message, opts) {
return this._enqueueAssertion(assertion_1.NotMatchAssertionCommand, { expected, message, opts });
}
}
exports.default = Assertion;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXJ0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwaS90ZXN0LWNvbnRyb2xsZXIvYXNzZXJ0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsaUVBa0IyQztBQUMzQyxvREFBd0U7QUFJeEUsd0RBQTRFO0FBQzVFLG9HQUFrRTtBQUNsRSwwRkFBa0U7QUFTbEUsTUFBcUIsU0FBUztJQUsxQixZQUFvQixNQUFlLEVBQUUsY0FBOEIsRUFBRSxRQUF3QjtRQUN6RixJQUFJLENBQUMsZUFBZSxHQUFHLGNBQWMsQ0FBQztRQUN0QyxJQUFJLENBQUMsT0FBTyxHQUFXLE1BQU0sQ0FBQztRQUM5QixJQUFJLENBQUMsU0FBUyxHQUFTLFFBQVEsQ0FBQztJQUNwQyxDQUFDO0lBRU0sSUFBSTtRQUNQLE1BQU0sSUFBSSwwQ0FBK0IsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDOUQsQ0FBQztJQUVPLGlCQUFpQixDQUFFLE9BQWdDLEVBQUUsYUFBNEI7UUFDckYsSUFBSSxPQUFPLEdBQUcsYUFBYSxDQUFDLElBQUksSUFBSSxFQUFFLENBQUM7UUFDdkMsSUFBSSxPQUFPLEdBQUcsYUFBYSxDQUFDLE9BQU8sQ0FBQztRQUVwQyw2RUFBNkU7UUFDN0UsaUVBQWlFO1FBQ2pFLDRHQUE0RztRQUM1RyxrREFBa0Q7UUFDbEQsSUF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