/** * @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 { MatButtonToggleHarness } from './button-toggle-harness'; /** Harness for interacting with a standard mat-button-toggle in tests. */ export class MatButtonToggleGroupHarness extends ComponentHarness { /** The selector for the host element of a `MatButton` instance. */ static { this.hostSelector = '.mat-button-toggle-group'; } /** * Gets a `HarnessPredicate` that can be used to search for a `MatButtonToggleGroupHarness` * that meets certain criteria. * @param options Options for filtering which button toggle instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(MatButtonToggleGroupHarness, options).addOption('disabled', options.disabled, async (harness, disabled) => { return (await harness.isDisabled()) === disabled; }); } /** * Gets the button toggles that are inside the group. * @param filter Optionally filters which toggles are included. */ async getToggles(filter = {}) { return this.locatorForAll(MatButtonToggleHarness.with(filter))(); } /** Gets whether the button toggle group is disabled. */ async isDisabled() { return (await (await this.host()).getAttribute('aria-disabled')) === 'true'; } /** Gets whether the button toggle group is laid out vertically. */ async isVertical() { return (await this.host()).hasClass('mat-button-toggle-vertical'); } /** Gets the appearance that the group is using. */ async getAppearance() { const host = await this.host(); const className = 'mat-button-toggle-group-appearance-standard'; return (await host.hasClass(className)) ? 'standard' : 'legacy'; } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnV0dG9uLXRvZ2dsZS1ncm91cC1oYXJuZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL2J1dHRvbi10b2dnbGUvdGVzdGluZy9idXR0b24tdG9nZ2xlLWdyb3VwLWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGdCQUFnQixFQUFFLGdCQUFnQixF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