/** * @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 { ComponentHarness, HarnessPredicate, } from '@angular/cdk/testing'; /** Harness for interacting with an MDC-based Angular Material tab link in tests. */ export class MatTabLinkHarness extends ComponentHarness { /** The selector for the host element of a `MatTabLink` instance. */ static { this.hostSelector = '.mat-mdc-tab-link'; } /** * Gets a `HarnessPredicate` that can be used to search for a tab link with specific attributes. * @param options Options for filtering which tab link instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(this, options).addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label)); } /** Gets the label of the link. */ async getLabel() { return (await this.host()).text(); } /** Whether the link is active. */ async isActive() { const host = await this.host(); return host.hasClass('mdc-tab--active'); } /** Whether the link is disabled. */ async isDisabled() { const host = await this.host(); return host.hasClass('mat-mdc-tab-disabled'); } /** Clicks on the link. */ async click() { await (await this.host()).click(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFiLWxpbmstaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC90YWJzL3Rlc3RpbmcvdGFiLWxpbmstaGFybmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQ0wsZ0JBQWdCLEVBRWhCLGdCQUFnQixHQUNqQixNQUFNLHNCQUFzQixDQUFDO0FBRzlCLG9GQUFvRjtBQUNwRixNQUFNLE9BQU8saUJBQWtCLFNBQVEsZ0JBQWdCO0lBQ3JELG9FQUFvRTthQUM3RCxpQkFBWSxHQUFHLG1CQUFtQixDQUFDO0lBRTFDOzs7O09BSUc7SUFDSCxNQUFNLENBQUMsSUFBSSxDQUVULFVBQWlDLEVBQUU7UUF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