/** * @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'; import { MatOptionHarness } from './option-harness'; /** Harness for interacting with an MDC-based `mat-optgroup` in tests. */ export class MatOptgroupHarness extends ComponentHarness { constructor() { super(...arguments); this._label = this.locatorFor('.mat-mdc-optgroup-label'); } /** Selector used to locate option group instances. */ static { this.hostSelector = '.mat-mdc-optgroup'; } /** * Gets a `HarnessPredicate` that can be used to search for a option group with specific * attributes. * @param options Options for filtering which option instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(this, options).addOption('labelText', options.labelText, async (harness, title) => HarnessPredicate.stringMatches(await harness.getLabelText(), title)); } /** Gets the option group's label text. */ async getLabelText() { return (await this._label()).text(); } /** Gets whether the option group is disabled. */ async isDisabled() { return (await (await this.host()).getAttribute('aria-disabled')) === 'true'; } /** * Gets the options that are inside the group. * @param filter Optionally filters which options are included. */ async getOptions(filter = {}) { return this.locatorForAll(MatOptionHarness.with(filter))(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0Z3JvdXAtaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9jb3JlL3Rlc3Rpbmcvb3B0Z3JvdXAtaGFybmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQ0wsZ0JBQWdCLEVBRWhCLGdCQUFnQixHQUNqQixNQUFNLHNCQUFzQixDQUFDO0FBRTlCLE9BQU8sRUFBQyxnQkFBZ0IsRUFBQyxNQUFNLGtCQUFrQixDQUFDO0FBR2xELHlFQUF5RTtBQUN6RSxNQUFNLE9BQU8sa0JBQW1CLFNBQVEsZ0J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