{"version":3,"file":"tooltip-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/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.dev/license\n */\n\nimport {\n  ComponentHarness,\n  ComponentHarnessConstructor,\n  HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {TooltipHarnessFilters} from './tooltip-harness-filters';\n\n/** Harness for interacting with a mat-tooltip in tests. */\nexport class MatTooltipHarness extends ComponentHarness {\n  static hostSelector = '.mat-mdc-tooltip-trigger';\n\n  private _optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-mdc-tooltip');\n  private _hiddenClass = 'mat-mdc-tooltip-hide';\n  private _disabledClass = 'mat-mdc-tooltip-disabled';\n  private _showAnimationName = 'mat-mdc-tooltip-show';\n  private _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<T extends MatTooltipHarness>(\n    this: ComponentHarnessConstructor<T>,\n    options: TooltipHarnessFilters = {},\n  ): HarnessPredicate<T> {\n    return new HarnessPredicate(this, options);\n  }\n\n  /** Shows the tooltip. */\n  async show(): Promise<void> {\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<void> {\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<boolean> {\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<boolean> {\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<string> {\n    const panel = await this._optionalPanel();\n    return panel ? panel.text() : '';\n  }\n}\n"],"names":[],"mappings":";;AAgBM,MAAO,iBAAkB,SAAQ,gBAAgB,CAAA;EACrD,OAAO,YAAY,GAAG,0BAA0B;EAExC,cAAc,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC,kBAAkB,CAAC,kBAAkB,CAAC;AACzF,EAAA,YAAY,GAAG,sBAAsB;AACrC,EAAA,cAAc,GAAG,0BAA0B;AAC3C,EAAA,kBAAkB,GAAG,sBAAsB;AAC3C,EAAA,kBAAkB,GAAG,sBAAsB;AAQnD,EAAA,OAAO,IAAI,CAET,OAAA,GAAiC,EAAE,EAAA;AAEnC,IAAA,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC;AAC5C,EAAA;AAGA,EAAA,MAAM,IAAI,GAAA;AACR,IAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE;AAK9B,IAAA,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;AAAC,MAAA,cAAc,EAAE;AAAE,KAAC,CAAC;AAC5D,IAAA,MAAM,IAAI,CAAC,KAAK,EAAE;AAClB,IAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE;AACzC,IAAA,MAAM,KAAK,EAAE,aAAa,CAAC,cAAc,EAAE;MAAC,aAAa,EAAE,IAAI,CAAC;AAAkB,KAAC,CAAC;AACtF,EAAA;AAGA,EAAA,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