@nova-ui/bits
Version:
SolarWinds Nova Framework
73 lines • 3.16 kB
JavaScript
// © 2022 SolarWinds Worldwide, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import { Atom } from "../../atom";
import { expect } from "../../setup";
import { ButtonAtom } from "../button/button.atom";
export class TextboxNumberAtom extends Atom {
static { this.CSS_CLASS = "nui-textbox-number"; }
constructor(locator) {
super(locator);
this.upButton = Atom.findIn(ButtonAtom, locator.locator(".nui-textbox-number__up-button"));
this.downButton = Atom.findIn(ButtonAtom, locator.locator(".nui-textbox-number__down-button"));
this.input = locator.locator(".nui-textbox__input");
}
async getValue() {
return await this.input.inputValue();
}
async getPlaceholder() {
return (await this.input.getAttribute("placeholder")) ?? "";
}
async acceptText(text) {
await this.input.fill("");
await this.input.type(text);
}
async clearText() {
await this.input.fill("");
}
async isDisabled() {
const disabled = await this.input.isDisabled();
const upDisabled = await this.upButton.isDisabled();
const downDisabled = await this.downButton.isDisabled();
return disabled && upDisabled && downDisabled;
}
async isReadonly() {
const readonly = await this.input.getAttribute("readonly");
const upDisabled = await this.upButton.isDisabled();
const downDisabled = await this.downButton.isDisabled();
return readonly !== null && upDisabled && downDisabled;
}
async isValid() {
const classList = await this.getLocator().getAttribute("class");
return !classList?.includes("has-error");
}
async toBeValid() {
await expect(this.getLocator()).not.toHaveClass(/has-error/);
}
async toBeInvalid() {
await expect(this.getLocator()).toHaveClass(/has-error/);
}
async toBeDisabled() {
await expect(this.input).toBeDisabled();
}
async toBeEnabled() {
await expect(this.input).toBeEnabled();
}
}
//# sourceMappingURL=textbox-number.atom.js.map