{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/expansion/testing/expansion-harness.ts","../../../../../../../src/material/expansion/testing/accordion-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 {\n ContentContainerComponentHarness,\n HarnessLoader,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {ExpansionPanelHarnessFilters} from './expansion-harness-filters';\n\n/** Selectors for the various `mat-expansion-panel` sections that may contain user content. */\nexport const enum MatExpansionPanelSection {\n HEADER = '.mat-expansion-panel-header',\n TITLE = '.mat-expansion-panel-header-title',\n DESCRIPTION = '.mat-expansion-panel-header-description',\n CONTENT = '.mat-expansion-panel-content',\n}\n\n/** Harness for interacting with a standard mat-expansion-panel in tests. */\nexport class MatExpansionPanelHarness extends ContentContainerComponentHarness {\n static hostSelector = '.mat-expansion-panel';\n\n private _header = this.locatorFor(MatExpansionPanelSection.HEADER);\n private _title = this.locatorForOptional(MatExpansionPanelSection.TITLE);\n private _description = this.locatorForOptional(MatExpansionPanelSection.DESCRIPTION);\n private _expansionIndicator = this.locatorForOptional('.mat-expansion-indicator');\n private _content = this.locatorFor(MatExpansionPanelSection.CONTENT);\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for an expansion-panel\n * with specific attributes.\n * @param options Options for narrowing the search:\n * - `title` finds an expansion-panel with a specific title text.\n * - `description` finds an expansion-panel with a specific description text.\n * - `expanded` finds an expansion-panel that is currently expanded.\n * - `disabled` finds an expansion-panel that is disabled.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(\n options: ExpansionPanelHarnessFilters = {},\n ): HarnessPredicate {\n return new HarnessPredicate(MatExpansionPanelHarness, options)\n .addOption('title', options.title, (harness, title) =>\n HarnessPredicate.stringMatches(harness.getTitle(), title),\n )\n .addOption('description', options.description, (harness, description) =>\n HarnessPredicate.stringMatches(harness.getDescription(), description),\n )\n .addOption('content', options.content, (harness, content) =>\n HarnessPredicate.stringMatches(harness.getTextContent(), content),\n )\n .addOption(\n 'expanded',\n options.expanded,\n async (harness, expanded) => (await harness.isExpanded()) === expanded,\n )\n .addOption(\n 'disabled',\n options.disabled,\n async (harness, disabled) => (await harness.isDisabled()) === disabled,\n );\n }\n\n /** Whether the panel is expanded. */\n async isExpanded(): Promise {\n return (await this.host()).hasClass('mat-expanded');\n }\n\n /**\n * Gets the title text of the panel.\n * @returns Title text or `null` if no title is set up.\n */\n async getTitle(): Promise {\n const titleEl = await this._title();\n return titleEl ? titleEl.text() : null;\n }\n\n /**\n * Gets the description text of the panel.\n * @returns Description text or `null` if no description is set up.\n */\n async getDescription(): Promise {\n const descriptionEl = await this._description();\n return descriptionEl ? descriptionEl.text() : null;\n }\n\n /** Whether the panel is disabled. */\n async isDisabled(): Promise {\n return (await (await this._header()).getAttribute('aria-disabled')) === 'true';\n }\n\n /**\n * Toggles the expanded state of the panel by clicking on the panel\n * header. This method will not work if the panel is disabled.\n */\n async toggle(): Promise {\n await (await this._header()).click();\n }\n\n /** Expands the expansion panel if collapsed. */\n async expand(): Promise {\n if (!(await this.isExpanded())) {\n await this.toggle();\n }\n }\n\n /** Collapses the expansion panel if expanded. */\n async collapse(): Promise {\n if (await this.isExpanded()) {\n await this.toggle();\n }\n }\n\n /** Gets the text content of the panel. */\n async getTextContent(): Promise {\n return (await this._content()).text();\n }\n\n /**\n * Gets a `HarnessLoader` that can be used to load harnesses for\n * components within the panel's content area.\n * @deprecated Use either `getChildLoader(MatExpansionPanelSection.CONTENT)`, `getHarness` or\n * `getAllHarnesses` instead.\n * @breaking-change 12.0.0\n */\n async getHarnessLoaderForContent(): Promise {\n return this.getChildLoader(MatExpansionPanelSection.CONTENT);\n }\n\n /** Focuses the panel. */\n async focus(): Promise {\n return (await this._header()).focus();\n }\n\n /** Blurs the panel. */\n async blur(): Promise {\n return (await this._header()).blur();\n }\n\n /** Whether the panel is focused. */\n async isFocused(): Promise {\n return (await this._header()).isFocused();\n }\n\n /** Whether the panel has a toggle indicator displayed. */\n async hasToggleIndicator(): Promise {\n return (await this._expansionIndicator()) !== null;\n }\n\n /** Gets the position of the toggle indicator. */\n async getToggleIndicatorPosition(): Promise<'before' | 'after'> {\n // By default the expansion indicator will show \"after\" the panel header content.\n if (await (await this._header()).hasClass('mat-expansion-toggle-indicator-before')) {\n return 'before';\n }\n return 'after';\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 {MatExpansionPanelHarness} from './expansion-harness';\nimport {AccordionHarnessFilters, ExpansionPanelHarnessFilters} from './expansion-harness-filters';\n\n/** Harness for interacting with a standard mat-accordion in tests. */\nexport class MatAccordionHarness extends ComponentHarness {\n static hostSelector = '.mat-accordion';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for an accordion\n * with specific attributes.\n * @param options Options for narrowing the search.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: AccordionHarnessFilters = {}): HarnessPredicate {\n return new HarnessPredicate(MatAccordionHarness, options);\n }\n\n /** Gets all expansion panels which are part of the accordion. */\n async getExpansionPanels(\n filter: ExpansionPanelHarnessFilters = {},\n ): Promise {\n return this.locatorForAll(MatExpansionPanelHarness.with(filter))();\n }\n\n /** Whether the accordion allows multiple expanded panels simultaneously. */\n async isMulti(): Promise {\n return (await this.host()).hasClass('mat-accordion-multi');\n }\n}\n"],"names":[],"mappings":";;AAuBA;AACM,MAAO,wBAAyB,SAAQ,gCAA0D,CAAA;AAAxG,IAAA,WAAA,GAAA;;AAGU,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,CAAC,UAAU,qEAAiC,CAAC;AAC3D,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,CAAC,kBAAkB,0EAAgC,CAAC;AACjE,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,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