UNPKG

ng-pom-testing

Version:

Utilities for easy DOM testing using the page-object-model pattern

41 lines (40 loc) 1.54 kB
"use strict"; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.POM = void 0; var POM = /** @class */ (function () { function POM(context, config) { this.context = context; this.config = config; } POM.prototype.validate = function (key) { if (!this.config.validate) { throw new Error('You must configure a validation object to use validate()'); } if (!this.config.validate[key]) { throw new Error("unrecognized validation: " + key + ", check your pom config file validate-property"); } this.config.validate[key](this.context); }; POM.prototype.action = function (key) { var _a; var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } if (!this.config.actions[key]) { throw new Error("unrecognized action: " + key + ", check your pom config file actions-property"); } return (_a = this.config.actions[key]).action.apply(_a, __spreadArray([this.context], args, false)); }; return POM; }()); exports.POM = POM;