/** * @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 { __awaiter } from "tslib"; import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing'; /** Harness for interacting with a standard Angular Material tab link in tests. */ export class MatTabLinkHarness extends ComponentHarness { /** * Gets a `HarnessPredicate` that can be used to search for a `MatTabLinkHarness` that meets * certain criteria. * @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(MatTabLinkHarness, options) .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label)); } /** Gets the label of the link. */ getLabel() { return __awaiter(this, void 0, void 0, function* () { return (yield this.host()).text(); }); } /** Whether the link is active. */ isActive() { return __awaiter(this, void 0, void 0, function* () { const host = yield this.host(); return host.hasClass('mat-tab-label-active'); }); } /** Whether the link is disabled. */ isDisabled() { return __awaiter(this, void 0, void 0, function* () { const host = yield this.host(); return host.hasClass('mat-tab-disabled'); }); } /** Clicks on the link. */ click() { return __awaiter(this, void 0, void 0, function* () { yield (yield this.host()).click(); }); } } /** The selector for the host element of a `MatTabLink` instance. */ MatTabLinkHarness.hostSelector = '.mat-tab-link'; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFiLWxpbmstaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC90YWJzL3Rlc3RpbmcvdGFiLWxpbmstaGFybmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7O0FBRUgsT0FBTyxFQUFDLGdCQUFnQixFQUFFLGdCQUFnQixFQUFDLE1BQU0sc0JBQXNCLENBQUM7QUFHeEUsa0ZBQWtGO0FBQ2xGLE1BQU0sT0FBTyxpQkFBa0IsU0FBUSxnQkFB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