@nova-ui/bits
Version:
SolarWinds Nova Framework
90 lines • 5.16 kB
JavaScript
"use strict";
// © 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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpanderAtom = void 0;
const tslib_1 = require("tslib");
const protractor_1 = require("protractor");
const atom_1 = require("../../atom");
const icon_atom_1 = require("../icon/icon.atom");
class ExpanderAtom extends atom_1.Atom {
constructor() {
super(...arguments);
this.root = this.getElement();
this.body = this.root.all(protractor_1.by.css(".nui-expander__body-wrapper")).first();
this.isExpanded = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return (yield this.body.getSize()).height > 0; });
this.isCollapsed = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return !(yield this.isExpanded()); });
this.isHeaderIconPresent = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
return icon_atom_1.IconAtom.findIn(icon_atom_1.IconAtom, this.getElement().element(protractor_1.by.css(".nui-expander__header-content-icon")))
.getElement()
.isPresent();
});
this.getExpanderToggleIcon = () => icon_atom_1.IconAtom.findIn(icon_atom_1.IconAtom, this.getElement().element(protractor_1.by.css(".nui-expander__header-icon")));
this.getBodyLeftBorderWidth = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.root
.all(protractor_1.by.css(".nui-expander__body"))
.first()
.getCssValue("border-left-width");
});
this.toggle = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.root.element(protractor_1.by.css(".nui-expander__header")).click();
// This is unfortunate, but there is no other way to wait for angular animation, other than doing a special build
// We should try to test it in units as good as possible
return protractor_1.browser.sleep(ExpanderAtom.animationDuration * 1.5);
});
this.getHeadingText = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.root
.element(protractor_1.by.css(".nui-expander__header-content-wrapper"))
.getText();
});
this.getHeaderHeight = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
return (yield this.root
.element(protractor_1.by.css(".nui-expander__header-title"))
.getSize()).height;
});
this.getCustomHeaderWidth = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
return (yield this.root
.element(protractor_1.by.css(".nui-expander__custom-header"))
.getSize()).width;
});
}
isContentDisplayed(cssSelectorSet) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!Array.isArray(cssSelectorSet)) {
cssSelectorSet = [cssSelectorSet];
}
const verifiers = cssSelectorSet.map((selector) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.root.element(protractor_1.by.css(selector)).isDisplayed(); }));
return Promise.all(verifiers).then((result) => result.every((resultItem) => resultItem));
});
}
isContentAttachedToDOM(cssSelectorSet) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!Array.isArray(cssSelectorSet)) {
cssSelectorSet = [cssSelectorSet];
}
const verifiers = cssSelectorSet.map((selector) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.root.element(protractor_1.by.css(selector)).isPresent(); }));
return Promise.all(verifiers).then((result) => result.every((resultItem) => resultItem));
});
}
}
exports.ExpanderAtom = ExpanderAtom;
ExpanderAtom.CSS_CLASS = "nui-expander";
ExpanderAtom.animationDuration = 350;
//# sourceMappingURL=expander.atom.js.map