/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { HarnessPredicate } from '@angular/cdk/testing'; import { MatListHarnessBase } from './list-harness-base'; import { getListItemPredicate, MatListItemHarnessBase } from './list-item-harness-base'; /** Harness for interacting with a MDC-based mat-nav-list in tests. */ export class MatNavListHarness extends MatListHarnessBase { constructor() { super(...arguments); this._itemHarness = MatNavListItemHarness; } /** The selector for the host element of a `MatNavList` instance. */ static { this.hostSelector = '.mat-mdc-nav-list'; } /** * Gets a `HarnessPredicate` that can be used to search for a nav list with specific * attributes. * @param options Options for filtering which nav list instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(this, options); } } /** Harness for interacting with a MDC-based nav-list item. */ export class MatNavListItemHarness extends MatListItemHarnessBase { /** The selector for the host element of a `MatListItem` instance. */ static { this.hostSelector = `${MatNavListHarness.hostSelector} .mat-mdc-list-item`; } /** * Gets a `HarnessPredicate` that can be used to search for a nav list item with specific * attributes. * @param options Options for filtering which nav list item instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return getListItemPredicate(this, options) .addOption('href', options.href, async (harness, href) => HarnessPredicate.stringMatches(harness.getHref(), href)) .addOption('activated', options.activated, async (harness, activated) => (await harness.isActivated()) === activated); } /** Gets the href for this nav list item. */ async getHref() { return (await this.host()).getAttribute('href'); } /** Clicks on the nav list item. */ async click() { return (await this.host()).click(); } /** Focuses the nav list item. */ async focus() { return (await this.host()).focus(); } /** Blurs the nav list item. */ async blur() { return (await this.host()).blur(); } /** Whether the nav list item is focused. */ async isFocused() { return (await this.host()).isFocused(); } /** Whether the list item is activated. Should only be used for nav list items. */ async isActivated() { return (await this.host()).hasClass('mdc-list-item--activated'); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmF2LWxpc3QtaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3V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