@viewstools/e2e
Advanced tools
Comparing version 0.1.2 to 0.1.3
26
index.js
@@ -1,9 +0,25 @@ | ||
const key = process.env.VIEWS_E2E_TEST_ID || "data-test-id"; | ||
const key = process.env.VIEWS_E2E_TEST_ID || 'data-test-id'; | ||
const get = (id, ...scopes) => () => { | ||
const el = browser.element(`[${key}*="${id}|"]`); | ||
const getElBySelector = ($in, selector, index, all) => { | ||
let el; | ||
if (typeof index === 'number') { | ||
// get item from list by index | ||
el = $in.elements(selector).value[index]; | ||
} else if (all) { | ||
// get all items from list | ||
el = $in.elements(selector).value; | ||
} else { | ||
el = $in.element(selector); | ||
} | ||
return el; | ||
}; | ||
const get = (id, ...scopes) => ({ all = false, $in = browser, index } = {}) => { | ||
const idSelector = `[${key}*="${id}|"]`; | ||
let el = getElBySelector($in, idSelector, index, all); | ||
scopes.forEach(scope => { | ||
el[scope] = () => | ||
browser.element(`[${key}*="${id}|"][${key}*="${scope}|"]`); | ||
getElBySelector($in, `${idSelector}[${key}*="${scope}|"`, index, all); | ||
}); | ||
@@ -15,3 +31,3 @@ | ||
module.exports = { | ||
get | ||
get, | ||
}; |
31
lib.js
@@ -1,3 +0,17 @@ | ||
var key = process.env.VIEWS_E2E_TEST_ID || "data-test-id"; | ||
var key = process.env.VIEWS_E2E_TEST_ID || 'data-test-id'; | ||
var getElBySelector = function ($in, selector, index, all) { | ||
var el; | ||
if (typeof index === 'number') { | ||
// get item from list by index | ||
el = $in.elements(selector).value[index]; | ||
} else if (all) { | ||
// get all items from list | ||
el = $in.elements(selector).value; | ||
} else { | ||
el = $in.element(selector); | ||
} | ||
return el; | ||
}; | ||
var get = function (id) { | ||
@@ -7,7 +21,14 @@ var scopes = [], len = arguments.length - 1; | ||
return function () { | ||
var el = browser.element(("[" + key + "*=\"" + id + "|\"]")); | ||
return function (ref) { | ||
if ( ref === void 0 ) ref = {}; | ||
var all = ref.all; if ( all === void 0 ) all = false; | ||
var $in = ref.$in; if ( $in === void 0 ) $in = browser; | ||
var index = ref.index; | ||
var idSelector = "[" + key + "*=\"" + id + "|\"]"; | ||
var el = getElBySelector($in, idSelector, index, all); | ||
scopes.forEach(function (scope) { | ||
el[scope] = function () { return browser.element(("[" + key + "*=\"" + id + "|\"][" + key + "*=\"" + scope + "|\"]")); }; | ||
el[scope] = function () { return getElBySelector($in, (idSelector + "[" + key + "*=\"" + scope + "|\""), index, all); }; | ||
}); | ||
@@ -20,4 +41,4 @@ | ||
module.exports = { | ||
get: get | ||
get: get, | ||
}; | ||
{ | ||
"name": "@viewstools/e2e", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Views Tools E2E helpers", | ||
@@ -5,0 +5,0 @@ "main": "lib.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5382
59