Innovenergy_trunk/frontend/node_modules/testcafe/lib/api/structure/fixture.js

84 lines
13 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 lodash_1 = require("lodash");
const testing_unit_1 = __importDefault(require("./testing-unit"));
const unit_type_1 = __importDefault(require("./unit-type"));
const type_assertions_1 = require("../../errors/runtime/type-assertions");
const handle_tag_args_1 = __importDefault(require("../../utils/handle-tag-args"));
const wrap_test_function_1 = __importDefault(require("../wrap-test-function"));
const assert_type_1 = __importDefault(require("../request-hooks/assert-type"));
const assert_type_2 = __importDefault(require("../../custom-client-scripts/assert-type"));
const option_names_1 = __importDefault(require("../../configuration/option-names"));
const runtime_1 = require("../../errors/runtime");
const types_1 = require("../../errors/types");
const testcafe_hammerhead_1 = require("testcafe-hammerhead");
class Fixture extends testing_unit_1.default {
constructor(testFile, baseUrl, returnApiOrigin = true) {
const pageUrl = baseUrl || testcafe_hammerhead_1.SPECIAL_BLANK_PAGE;
super(testFile, unit_type_1.default.fixture, pageUrl, baseUrl);
this.path = testFile.filename;
this.beforeEachFn = null;
this.afterEachFn = null;
this.beforeFn = null;
this.afterFn = null;
this.globalBeforeFn = null;
this.globalAfterFn = null;
if (returnApiOrigin)
return this.apiOrigin;
}
static init({ testFile, baseUrl }) {
return super.init(Fixture, testFile, baseUrl);
}
_add(name, ...rest) {
name = (0, handle_tag_args_1.default)(name, rest);
(0, type_assertions_1.assertType)(type_assertions_1.is.string, 'apiOrigin', 'The fixture name', name);
this.name = name;
this.testFile.currentFixture = this;
return this.apiOrigin;
}
_before$(fn) {
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'before', 'The fixture.before hook', fn);
this.beforeFn = fn;
return this.apiOrigin;
}
_after$(fn) {
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'after', 'The fixture.after hook', fn);
this.afterFn = fn;
return this.apiOrigin;
}
_beforeEach$(fn) {
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'beforeEach', 'The fixture.beforeEach hook', fn);
this.beforeEachFn = (0, wrap_test_function_1.default)(fn);
return this.apiOrigin;
}
_afterEach$(fn) {
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'afterEach', 'The fixture.afterEach hook', fn);
this.afterEachFn = (0, wrap_test_function_1.default)(fn);
return this.apiOrigin;
}
_requestHooks$(...hooks) {
if (this.apiMethodWasCalled.requestHooks)
throw new runtime_1.APIError(option_names_1.default.requestHooks, types_1.RUNTIME_ERRORS.multipleAPIMethodCallForbidden, option_names_1.default.requestHooks);
hooks = (0, lodash_1.flattenDeep)(hooks);
(0, assert_type_1.default)(hooks);
this.requestHooks = hooks;
this.apiMethodWasCalled.requestHooks = true;
return this.apiOrigin;
}
_clientScripts$(...scripts) {
if (this.apiMethodWasCalled.clientScripts)
throw new runtime_1.APIError(option_names_1.default.clientScripts, types_1.RUNTIME_ERRORS.multipleAPIMethodCallForbidden, option_names_1.default.clientScripts);
scripts = (0, lodash_1.flattenDeep)(scripts);
(0, assert_type_2.default)(scripts);
this.clientScripts = scripts;
this.apiMethodWasCalled.clientScripts = true;
return this.apiOrigin;
}
}
exports.default = Fixture;
testing_unit_1.default.makeAPIListForChildClass(Fixture);
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZml4dHVyZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGkvc3RydWN0dXJlL2ZpeHR1cmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxtQ0FBZ0Q7QUFDaEQsa0VBQXlDO0FBQ3pDLDREQUFtQztBQUNuQywwRUFBc0U7QUFDdEUsa0ZBQXdEO0FBQ3hELCtFQUFxRDtBQUNyRCwrRUFBaUU7QUFDakUsMEZBQTZFO0FBQzdFLG9GQUE0RDtBQUM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