@o3r/testing
Version:
The module provides testing (e2e, unit test) utilities to help you build your own E2E pipeline integrating visual testing.
39 lines • 1.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.O3rSelectElement = void 0;
const platform_browser_1 = require("@angular/platform-browser");
const element_1 = require("../element");
/**
* Implementation dedicated to angular / TestBed.
*/
class O3rSelectElement extends element_1.O3rElement {
constructor(sourceElement) {
super(sourceElement);
}
/** @inheritdoc */
async selectByIndex(index, _timeout) {
const options = this.sourceElement.queryAll(platform_browser_1.By.css('option'));
if (options[index]) {
const option = new element_1.O3rElement(options[index]);
const value = await option.getValue();
await this.setValue(value);
this.sourceElement.triggerEventHandler('change', { target: this.sourceElement.nativeElement, preventDefault: () => { }, stopPropagation: () => { } });
}
else {
return Promise.reject(new Error(`Option with index ${index} not found in select element.`));
}
}
/** @inheritdoc */
async selectByValue(value, _timeout) {
const option = this.sourceElement.query(platform_browser_1.By.css(`option[value='${value}']`));
if (option) {
await this.setValue(option.nativeElement.value);
return this.sourceElement.triggerEventHandler('change', { target: this.sourceElement.nativeElement, preventDefault: () => { }, stopPropagation: () => { } });
}
else {
return Promise.reject(new Error(`Option with value '${value}' not found in select element.`));
}
}
}
exports.O3rSelectElement = O3rSelectElement;
//# sourceMappingURL=select-element.js.map