@nova-ui/bits
Version:
SolarWinds Nova Framework
67 lines • 2.38 kB
JavaScript
import { Atom } from "../../atom";
import { expect } from "../../setup";
export class CheckboxAtom extends Atom {
constructor() {
super(...arguments);
this.hoverLink = async () => {
await this.getLink().hover();
};
this.isIndeterminate = async () => {
// broken in application code, needs to be fixed there
// await expect(this.getInputElement).toHaveAttribute("indeterminate");
console.log("Checkbox indeterminate state cannot be tested due to application code issue.");
};
this.isRequired = async () => (await this.getInputElement.getAttribute("required")) === "true";
this.isDisabled = async () => !(await this.getInputElement.isEnabled());
this.isChecked = async () => (await this.getInputElement.getAttribute("checked")) === "true";
this.toBeChecked = async () => {
await expect(this.getInputElement).toBeChecked();
};
this.toNotBeChecked = async () => {
await expect(this.getInputElement).not.toBeChecked();
};
/**
* Toggle the checkbox value
*
* @returns {Promise<void>}
*/
this.toggle = async () => this.getMark().click();
}
static { this.CSS_CLASS = "nui-checkbox"; }
get getInputElement() {
return super.getLocator().locator(".nui-checkbox__input");
}
get getLabel() {
return super.getLocator().locator(".nui-checkbox__label");
}
get getContent() {
return super.getLocator().locator(".nui-checkbox__transclude");
}
get getHelpHintText() {
return super.getLocator().locator(".nui-help-hint");
}
/**
* Sets the checkbox value to the given value
*
* @param {boolean} checked
* @returns {Promise<void>}
*/
async setChecked(checked) {
if ((await this.isChecked()) !== checked) {
return await this.toggle();
}
}
getMark() {
return super.getLocator().locator(".nui-checkbox__mark");
}
getLink() {
return super.getLocator().locator(".link-in-checkbox");
}
async toBeDisabled() {
await expect(this.getInputElement).toBeDisabled();
}
async toBeEnabled() {
await expect(this.getInputElement).toBeEnabled();
}
}
//# sourceMappingURL=checkbox.atom.js.map