{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/tooltip/testing/tooltip-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 AsyncFactoryFn,\n ComponentHarness,\n ComponentHarnessConstructor,\n HarnessPredicate,\n TestElement,\n} from '@angular/cdk/testing';\nimport {TooltipHarnessFilters} from './tooltip-harness-filters';\n\nexport abstract class _MatTooltipHarnessBase extends ComponentHarness {\n protected abstract _optionalPanel: AsyncFactoryFn;\n protected abstract _hiddenClass: string;\n protected abstract _disabledClass: string;\n protected abstract _showAnimationName: string;\n protected abstract _hideAnimationName: string;\n\n /** Shows the tooltip. */\n async show(): Promise {\n const host = await this.host();\n\n // We need to dispatch both `touchstart` and a hover event, because the tooltip binds\n // different events depending on the device. The `changedTouches` is there in case the\n // element has ripples.\n await host.dispatchEvent('touchstart', {changedTouches: []});\n await host.hover();\n const panel = await this._optionalPanel();\n await panel?.dispatchEvent('animationend', {animationName: this._showAnimationName});\n }\n\n /** Hides the tooltip. */\n async hide(): Promise {\n const host = await this.host();\n\n // We need to dispatch both `touchstart` and a hover event, because\n // the tooltip binds different events depending on the device.\n await host.dispatchEvent('touchend');\n await host.mouseAway();\n const panel = await this._optionalPanel();\n await panel?.dispatchEvent('animationend', {animationName: this._hideAnimationName});\n }\n\n /** Gets whether the tooltip is open. */\n async isOpen(): Promise {\n const panel = await this._optionalPanel();\n return !!panel && !(await panel.hasClass(this._hiddenClass));\n }\n\n /** Gets whether the tooltip is disabled */\n async isDisabled(): Promise {\n const host = await this.host();\n return host.hasClass(this._disabledClass);\n }\n\n /** Gets a promise for the tooltip panel's text. */\n async getTooltipText(): Promise {\n const panel = await this._optionalPanel();\n return panel ? panel.text() : '';\n }\n}\n\n/** Harness for interacting with a standard mat-tooltip in tests. */\nexport class MatTooltipHarness extends _MatTooltipHarnessBase {\n protected _optionalPanel =\n this.documentRootLocatorFactory().locatorForOptional('.mat-mdc-tooltip');\n static hostSelector = '.mat-mdc-tooltip-trigger';\n protected _hiddenClass = 'mat-mdc-tooltip-hide';\n protected _disabledClass = 'mat-mdc-tooltip-disabled';\n protected _showAnimationName = 'mat-mdc-tooltip-show';\n protected _hideAnimationName = 'mat-mdc-tooltip-hide';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a tooltip trigger with specific\n * attributes.\n * @param options Options for narrowing the search.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(\n this: ComponentHarnessConstructor,\n options: TooltipHarnessFilters = {},\n ): HarnessPredicate {\n return new HarnessPredicate(this, options);\n }\n}\n"],"names":[],"mappings":";;AAiBM,MAAgB,sBAAuB,SAAQ,gBAAgB,CAAA;;AAQnE,IAAA,MAAM,IAAI,GAAA;AACR,QAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;;;AAK/B,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,EAAC,cAAc,EAAE,EAAE,EAAC,CAAC,CAAC;AAC7D,QAAA,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;AACnB,QAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;AAC1C,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,cAAc,EAAE,EAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAC,CAAC,CAAC;KACtF;;AAGD,IAAA,MAAM,IAAI,GAAA;AACR,QAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;;AAI/B,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACrC,QAAA,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;AACvB,QAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;AAC1C,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,cAAc,EA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