UNPKG

angular-sidebar-menu

Version:

The sources for this package are in the [Angular Sidebar Menu](https://github.com/mledour/angular-sidebar-menu) repo. Please file issues and pull requests against that repo.

73 lines (68 loc) 2.98 kB
import { __awaiter } from 'tslib'; import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing'; class MenuItemHarness extends ComponentHarness { constructor() { super(...arguments); this.getLabelElement = this.locatorFor('.asm-menu-anchor__label, .asm-menu-item__header'); this.getLinkElement = this.locatorFor('asm-menu-anchor a'); this.getBadgesElement = this.locatorForAll('.asm-badges__badge'); } static with(options) { return new HarnessPredicate(MenuItemHarness, options).addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getItemLabel(), label)); } getItemLabel() { return __awaiter(this, void 0, void 0, function* () { const el = yield this.getLabelElement(); return el.text(); }); } isFiltered() { return __awaiter(this, void 0, void 0, function* () { const el = yield this.host(); return el.hasClass('asm-menu-item--filtered'); }); } } MenuItemHarness.hostSelector = '[asm-menu-item]'; class MenuHarness extends ComponentHarness { constructor() { super(...arguments); this.getItems = this.locatorForAll(MenuItemHarness); this.getItemsHeaders = this.locatorForAll('.asm-menu-item__header'); this.getItemsWithIcons = this.locatorForAll('.asm-menu-anchor__icon'); this.getItemsWithBadges = this.locatorForAll('.asm-badges'); this.getActivatedAnchors = this.locatorForAll('.asm-menu-anchor--active'); this.getActivatedAnchorsLabels = this.locatorForAll('.asm-menu-anchor--active .asm-menu-anchor__label'); this.getOpenedNodes = this.locatorForAll('.asm-menu-node--open'); this.getOpenedNodesLabels = this.locatorForAll('.asm-menu-anchor--open .asm-menu-anchor__label'); this.getDisabledItems = this.locatorForAll('.asm-menu-item--disabled'); this.getFilteredItems = this.locatorForAll('.asm-menu-item--filtered'); } getItemsWith(filters = {}) { return __awaiter(this, void 0, void 0, function* () { const getFilteredItems = this.locatorForAll(MenuItemHarness.with(filters)); return getFilteredItems(); }); } getItemWith(filters = {}) { return __awaiter(this, void 0, void 0, function* () { const getFilteredItem = this.locatorFor(MenuItemHarness.with(filters)); return getFilteredItem(); }); } clickItemWith(filters = {}) { return __awaiter(this, void 0, void 0, function* () { const item = yield this.getItemWith(filters); return (yield item.getLinkElement()).click(); }); } } MenuHarness.hostSelector = 'asm-angular-sidebar-menu'; /* * Public API Surface of angular-sidebar-menu-testing */ /** * Generated bundle index. Do not edit. */ export { MenuHarness }; //# sourceMappingURL=angular-sidebar-menu-testing.js.map