{"version":3,"file":"ngx-com-components-tooltip-testing.mjs","sources":["../../../projects/com/components/tooltip/testing/tooltip.harness.ts","../../../projects/com/components/tooltip/testing/index.ts","../../../projects/com/components/tooltip/testing/ngx-com-components-tooltip-testing.ts"],"sourcesContent":["import {\n  ComponentHarness,\n  HarnessPredicate,\n  TestKey,\n} from '@angular/cdk/testing';\nimport type { BaseHarnessFilters } from '@angular/cdk/testing';\n\n/** Harness filters for ComTooltipHarness. */\nexport interface ComTooltipHarnessFilters extends BaseHarnessFilters {\n  /** Filter by the trigger element's text content. */\n  text?: string | RegExp;\n}\n\n/**\n * Harness for interacting with a `[comTooltip]` directive in tests.\n *\n * The tooltip panel is rendered in a CDK overlay, so this harness uses\n * `documentRootLocatorFactory()` to locate the panel in the document root.\n */\nexport class ComTooltipHarness extends ComponentHarness {\n  static hostSelector = '[comTooltip]';\n\n  private readonly documentRootLocator = this.documentRootLocatorFactory();\n\n  /**\n   * Gets a HarnessPredicate for matching tooltip triggers.\n   * @param options Filter options.\n   */\n  static with(options: ComTooltipHarnessFilters = {}): HarnessPredicate<ComTooltipHarness> {\n    return new HarnessPredicate(ComTooltipHarness, options)\n      .addOption('text', options.text, async (harness, text) => {\n        const triggerText = await harness.getText();\n        return HarnessPredicate.stringMatches(triggerText, text);\n      });\n  }\n\n  /** Gets the trigger element's text content. */\n  async getText(): Promise<string> {\n    const host = await this.host();\n    return host.text();\n  }\n\n  /** Whether the tooltip is currently open/visible. */\n  async isOpen(): Promise<boolean> {\n    const host = await this.host();\n    const describedBy = await host.getAttribute('aria-describedby');\n    return describedBy !== null;\n  }\n\n  /**\n   * Shows the tooltip by hovering over the trigger element.\n   * If the tooltip is already open, this is a no-op.\n   */\n  async show(): Promise<void> {\n    if (await this.isOpen()) {\n      return;\n    }\n    const host = await this.host();\n    await host.hover();\n    await this.forceStabilize();\n  }\n\n  /**\n   * Hides the tooltip by pressing Escape on the trigger element.\n   * If the tooltip is already closed, this is a no-op.\n   */\n  async hide(): Promise<void> {\n    if (!(await this.isOpen())) {\n      return;\n    }\n    const host = await this.host();\n    await host.sendKeys(TestKey.ESCAPE);\n    await this.forceStabilize();\n  }\n\n  /**\n   * Gets the text content of the tooltip panel.\n   * Returns `null` if the tooltip is not open.\n   */\n  async getTooltipText(): Promise<string | null> {\n    if (!(await this.isOpen())) {\n      return null;\n    }\n    const tooltipEl = await this.documentRootLocator.locatorForOptional(\n      'com-tooltip-panel [role=\"tooltip\"]',\n    )();\n    if (!tooltipEl) {\n      return null;\n    }\n    return tooltipEl.text();\n  }\n\n  /**\n   * Gets the side the tooltip is positioned on (`data-side` attribute).\n   * Returns `null` if the tooltip is not open.\n   */\n  async getTooltipSide(): Promise<string | null> {\n    if (!(await this.isOpen())) {\n      return null;\n    }\n    const panelWrapper = await this.documentRootLocator.locatorForOptional(\n      'com-tooltip-panel [data-side]',\n    )();\n    if (!panelWrapper) {\n      return null;\n    }\n    return panelWrapper.getAttribute('data-side');\n  }\n\n  /** Gets the `aria-describedby` value from the trigger element. */\n  async getAriaDescribedBy(): Promise<string | null> {\n    const host = await this.host();\n    return host.getAttribute('aria-describedby');\n  }\n\n  /** Focuses the trigger element (also shows the tooltip via focusin). */\n  async focus(): Promise<void> {\n    const host = await this.host();\n    await host.focus();\n    await this.forceStabilize();\n  }\n\n  /** Blurs the trigger element (hides the tooltip via focusout). */\n  async blur(): Promise<void> {\n    const host = await this.host();\n    await host.blur();\n    await this.forceStabilize();\n  }\n\n  /** Whether the trigger element is currently focused. */\n  async isFocused(): Promise<boolean> {\n    const host = await this.host();\n    return host.isFocused();\n  }\n}\n","// Testing utilities for the tooltip directive\n\nexport { ComTooltipHarness } from './tooltip.harness';\n\nexport type { ComTooltipHarnessFilters } from './tooltip.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAaA;;;;;AAKG;AACG,MAAO,iBAAkB,SAAQ,gBAAgB,CAAA;AACrD,IAAA,OAAO,YAAY,GAAG,cAAc;AAEnB,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