{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/button-toggle/testing/button-toggle-harness.ts","../../../../../../../src/material/button-toggle/testing/button-toggle-group-harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';\nimport {coerceBooleanProperty} from '@angular/cdk/coercion';\nimport {MatButtonToggleAppearance} from '@angular/material/button-toggle';\nimport {ButtonToggleHarnessFilters} from './button-toggle-harness-filters';\n\n/** Harness for interacting with a standard mat-button-toggle in tests. */\nexport class MatButtonToggleHarness extends ComponentHarness {\n /** The selector for the host element of a `MatButton` instance. */\n static hostSelector = '.mat-button-toggle';\n\n private _label = this.locatorFor('.mat-button-toggle-label-content');\n private _button = this.locatorFor('.mat-button-toggle-button');\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a `MatButtonToggleHarness` that meets\n * certain criteria.\n * @param options Options for filtering which button toggle instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: ButtonToggleHarnessFilters = {}): HarnessPredicate {\n return new HarnessPredicate(MatButtonToggleHarness, options)\n .addOption('text', options.text, (harness, text) =>\n HarnessPredicate.stringMatches(harness.getText(), text),\n )\n .addOption('name', options.name, (harness, name) =>\n HarnessPredicate.stringMatches(harness.getName(), name),\n )\n .addOption(\n 'checked',\n options.checked,\n async (harness, checked) => (await harness.isChecked()) === checked,\n )\n .addOption('disabled', options.disabled, async (harness, disabled) => {\n return (await harness.isDisabled()) === disabled;\n });\n }\n\n /** Gets a boolean promise indicating if the button toggle is checked. */\n async isChecked(): Promise {\n const checked = (await this._button()).getAttribute('aria-pressed');\n return coerceBooleanProperty(await checked);\n }\n\n /** Gets a boolean promise indicating if the button toggle is disabled. */\n async isDisabled(): Promise {\n const disabled = (await this._button()).getAttribute('disabled');\n return coerceBooleanProperty(await disabled);\n }\n\n /** Gets a promise for the button toggle's name. */\n async getName(): Promise {\n return (await this._button()).getAttribute('name');\n }\n\n /** Gets a promise for the button toggle's aria-label. */\n async getAriaLabel(): Promise {\n return (await this._button()).getAttribute('aria-label');\n }\n\n /** Gets a promise for the button toggles's aria-labelledby. */\n async getAriaLabelledby(): Promise {\n return (await this._button()).getAttribute('aria-labelledby');\n }\n\n /** Gets a promise for the button toggle's text. */\n async getText(): Promise {\n return (await this._label()).text();\n }\n\n /** Gets the appearance that the button toggle is using. */\n async getAppearance(): Promise {\n const host = await this.host();\n const className = 'mat-button-toggle-appearance-standard';\n return (await host.hasClass(className)) ? 'standard' : 'legacy';\n }\n\n /** Focuses the toggle. */\n async focus(): Promise {\n return (await this._button()).focus();\n }\n\n /** Blurs the toggle. */\n async blur(): Promise {\n return (await this._button()).blur();\n }\n\n /** Whether the toggle is focused. */\n async isFocused(): Promise {\n return (await this._button()).isFocused();\n }\n\n /** Toggle the checked state of the buttons toggle. */\n async toggle(): Promise {\n return (await this._button()).click();\n }\n\n /**\n * Puts the button toggle in a checked state by toggling it if it's\n * currently unchecked, or doing nothing if it is already checked.\n */\n async check(): Promise {\n if (!(await this.isChecked())) {\n await this.toggle();\n }\n }\n\n /**\n * Puts the button toggle in an unchecked state by toggling it if it's\n * currently checked, or doing nothing if it's already unchecked.\n */\n async uncheck(): Promise {\n if (await this.isChecked()) {\n await this.toggle();\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';\nimport {MatButtonToggleAppearance} from '@angular/material/button-toggle';\nimport {ButtonToggleGroupHarnessFilters} from './button-toggle-group-harness-filters';\nimport {ButtonToggleHarnessFilters} from './button-toggle-harness-filters';\nimport {MatButtonToggleHarness} from './button-toggle-harness';\n\n/** Harness for interacting with a standard mat-button-toggle in tests. */\nexport class MatButtonToggleGroupHarness extends ComponentHarness {\n /** The selector for the host element of a `MatButton` instance. */\n static hostSelector = '.mat-button-toggle-group';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a `MatButtonToggleGroupHarness`\n * that meets certain criteria.\n * @param options Options for filtering which button toggle instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(\n options: ButtonToggleGroupHarnessFilters = {},\n ): HarnessPredicate {\n return new HarnessPredicate(MatButtonToggleGroupHarness, options).addOption(\n 'disabled',\n options.disabled,\n async (harness, disabled) => {\n return (await harness.isDisabled()) === disabled;\n },\n );\n }\n\n /**\n * Gets the button toggles that are inside the group.\n * @param filter Optionally filters which toggles are included.\n */\n async getToggles(filter: ButtonToggleHarnessFilters = {}): Promise {\n return this.locatorForAll(MatButtonToggleHarness.with(filter))();\n }\n\n /** Gets whether the button toggle group is disabled. */\n async isDisabled(): Promise {\n return (await (await this.host()).getAttribute('aria-disabled')) === 'true';\n }\n\n /** Gets whether the button toggle group is laid out vertically. */\n async isVertical(): Promise {\n return (await this.host()).hasClass('mat-button-toggle-vertical');\n }\n\n /** Gets the appearance that the group is using. */\n async getAppearance(): Promise {\n const host = await this.host();\n const className = 'mat-button-toggle-group-appearance-standard';\n return (await host.hasClass(className)) ? 'standard' : 'legacy';\n }\n}\n"],"names":[],"mappings":";;;AAaA;AACM,MAAO,sBAAuB,SAAQ,gBAAgB,CAAA;AAA5D,IAAA,WAAA,GAAA;;AAIU,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC;AAC7D,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAC;KAwGhE;;aA3GQ,IAAY,CAAA,YAAA,GAAG,oBAAH,CAAwB,EAAA;AAK3C;;;;;AAKG;AACH,IAAA,OAAO,IAAI,CAAC,OAAA,GAAsC,EAAE,EAAA;AAClD,QAAA,OAAO,IAAI,gBAAgB,CAAC,sBAAsB,EAAE,OAAO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