@atomic-testing/component-driver-html
Advanced tools
Comparing version 0.25.0 to 0.26.0
import { ComponentDriver, IInputDriver, Nullable } from '@atomic-testing/core'; | ||
import { HTMLOptionDriver } from './HTMLOptionDriver'; | ||
type ValueT = string | readonly string[]; | ||
@@ -8,3 +7,2 @@ export declare class HTMLSelectDriver extends ComponentDriver<{}> implements IInputDriver<Nullable<ValueT>> { | ||
setValue(value: Nullable<ValueT>): Promise<boolean>; | ||
getOptionByIndex(index: number): Promise<HTMLOptionDriver | null>; | ||
getValuesByLabels(labels: readonly string[]): Promise<readonly string[]>; | ||
@@ -11,0 +9,0 @@ selectByLabel(label: string | readonly string[]): Promise<void>; |
@@ -11,2 +11,9 @@ "use strict"; | ||
}; | ||
var __asyncValues = (this && this.__asyncValues) || function (o) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var m = o[Symbol.asyncIterator], i; | ||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); | ||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } | ||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -42,23 +49,32 @@ exports.HTMLSelectDriver = void 0; | ||
} | ||
getOptionByIndex(index) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const itemLocatorBase = core_1.locatorUtil.append(this.locator, optionLocator); | ||
return core_1.driverHelper.getListItemByIndex(this, itemLocatorBase, index, HTMLOptionDriver_1.HTMLOptionDriver); | ||
}); | ||
} | ||
getValuesByLabels(labels) { | ||
var _a, e_1, _b, _c; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const labelSet = new Set(labels); | ||
let index = 0; | ||
let item = yield this.getOptionByIndex(index); | ||
const values = []; | ||
while (item != null) { | ||
const label = yield item.label(); | ||
const value = yield item.value(); | ||
if (label != null && labelSet.has(label) && value != null) { | ||
values.push(value); | ||
const itemLocatorBase = core_1.locatorUtil.append(this.locator, optionLocator); | ||
try { | ||
for (var _d = true, _e = __asyncValues(core_1.driverHelper.getListItemIterator(this, itemLocatorBase, HTMLOptionDriver_1.HTMLOptionDriver)), _f; _f = yield _e.next(), _a = _f.done, !_a;) { | ||
_c = _f.value; | ||
_d = false; | ||
try { | ||
let item = _c; | ||
const label = yield item.label(); | ||
const value = yield item.value(); | ||
if (label != null && labelSet.has(label) && value != null) { | ||
values.push(value); | ||
} | ||
} | ||
finally { | ||
_d = true; | ||
} | ||
} | ||
index++; | ||
item = yield this.getOptionByIndex(index); | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return values; | ||
@@ -65,0 +81,0 @@ }); |
{ | ||
"name": "@atomic-testing/component-driver-html", | ||
"version": "0.25.0", | ||
"version": "0.26.0", | ||
"description": "HTML component driver for atomic-testing", | ||
@@ -25,3 +25,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@atomic-testing/core": "0.25.0" | ||
"@atomic-testing/core": "0.26.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -30,13 +30,7 @@ import { byTagName, ComponentDriver, driverHelper, IInputDriver, locatorUtil, Nullable } from '@atomic-testing/core'; | ||
async getOptionByIndex(index: number): Promise<HTMLOptionDriver | null> { | ||
const itemLocatorBase = locatorUtil.append(this.locator, optionLocator); | ||
return driverHelper.getListItemByIndex(this, itemLocatorBase, index, HTMLOptionDriver); | ||
} | ||
async getValuesByLabels(labels: readonly string[]): Promise<readonly string[]> { | ||
const labelSet = new Set(labels); | ||
let index = 0; | ||
let item: HTMLOptionDriver | null = await this.getOptionByIndex(index); | ||
const values: string[] = []; | ||
while (item != null) { | ||
const itemLocatorBase = locatorUtil.append(this.locator, optionLocator); | ||
for await (let item of driverHelper.getListItemIterator(this, itemLocatorBase, HTMLOptionDriver)) { | ||
const label = await item.label(); | ||
@@ -47,4 +41,2 @@ const value = await item.value(); | ||
} | ||
index++; | ||
item = await this.getOptionByIndex(index); | ||
} | ||
@@ -51,0 +43,0 @@ return values; |
Sorry, the diff of this file is not supported yet
51700
837
+ Added@atomic-testing/core@0.26.0(transitive)
- Removed@atomic-testing/core@0.25.0(transitive)
Updated@atomic-testing/core@0.26.0