{"version":3,"file":"skyux-errors-testing.mjs","sources":["../../../../../libs/components/errors/testing/src/legacy/error-fixture.ts","../../../../../libs/components/errors/testing/src/modules/error/error-action-harness.ts","../../../../../libs/components/errors/testing/src/modules/error/error-image-harness.ts","../../../../../libs/components/errors/testing/src/modules/error/error-harness.ts","../../../../../libs/components/errors/testing/src/modules/error/error-modal-harness.ts","../../../../../libs/components/errors/testing/src/skyux-errors-testing.ts"],"sourcesContent":["import { DebugElement } from '@angular/core';\nimport { ComponentFixture } from '@angular/core/testing';\nimport { By } from '@angular/platform-browser';\nimport { SkyAppTestUtility } from '@skyux-sdk/testing';\n\nconst SKY_ERROR_IMAGE_CLS_REGEX = /^sky-error-(\\w*)-image$/;\n\n/**\n * Allows interaction with a SKY UX error component.\n * @deprecated Use `SkyErrorHarness` instead.\n * @internal\n */\nexport class SkyErrorFixture {\n  /**\n   * The error's current type.\n   */\n  public get errorType(): string | undefined {\n    const imageEl = this.#debugEl.query(\n      By.css('.sky-error-image-container > div'),\n    );\n\n    if (imageEl) {\n      const classList = imageEl.nativeElement.classList;\n\n      for (let i = 0, n = classList.length; i < n; i++) {\n        const cls = classList.item(i);\n        const matches = SKY_ERROR_IMAGE_CLS_REGEX.exec(cls);\n\n        /* istanbul ignore else */\n        if (matches) {\n          return matches[1];\n        }\n      }\n    }\n\n    return undefined;\n  }\n\n  #debugEl: DebugElement;\n\n  constructor(fixture: ComponentFixture<unknown>, skyTestId: string) {\n    this.#debugEl = SkyAppTestUtility.getDebugElementByTestId(\n      fixture,\n      skyTestId,\n      'sky-error',\n    );\n  }\n}\n","import { SkyQueryableComponentHarness } from '@skyux/core/testing';\n\n/**\n * Harness for interacting with an error action component in tests.\n */\nexport class SkyErrorActionHarness extends SkyQueryableComponentHarness {\n  /**\n   * @internal\n   */\n  public static hostSelector = 'sky-error-action';\n}\n","import { SkyQueryableComponentHarness } from '@skyux/core/testing';\n\n/**\n * Harness for interacting with an error image component in tests.\n */\nexport class SkyErrorImageHarness extends SkyQueryableComponentHarness {\n  /**\n   * @internal\n   */\n  public static hostSelector = 'sky-error-image';\n}\n","import { HarnessPredicate, TestElement } from '@angular/cdk/testing';\nimport { SkyComponentHarness } from '@skyux/core/testing';\nimport { SkyErrorType } from '@skyux/errors';\n\nimport { SkyErrorActionHarness } from './error-action-harness';\nimport { SkyErrorHarnessFilters } from './error-harness-filters';\nimport { SkyErrorImageHarness } from './error-image-harness';\n\n/**\n * Harness for interacting with an error component in tests.\n */\nexport class SkyErrorHarness extends SkyComponentHarness {\n  /**\n   * @internal\n   */\n  public static hostSelector = 'sky-error';\n\n  #actionButton = this.locatorForOptional('sky-error-action button');\n  #description = this.locatorFor('.sky-error-description');\n  #imageContainer = this.locatorForOptional('.sky-error-image-container');\n  #title = this.locatorFor('.sky-error-title');\n\n  /**\n   * Gets a `HarnessPredicate` that can be used to search for a\n   * `SkyErrorHarness` that meets certain criteria.\n   */\n  public static with(\n    filters: SkyErrorHarnessFilters,\n  ): HarnessPredicate<SkyErrorHarness> {\n    return SkyErrorHarness.getDataSkyIdPredicate(filters);\n  }\n\n  /**\n   * Clicks the action button in the error action.\n   */\n  public async clickActionButton(): Promise<void> {\n    await (await this.#getAction()).click();\n  }\n\n  /**\n   * Gets the text of the action button in the error action.\n   */\n  public async getActionButtonText(): Promise<string> {\n    return await (await this.#getAction()).text();\n  }\n\n  /**\n   * Gets the description of the error.\n   */\n  public async getDescription(): Promise<string> {\n    return await (await this.#description()).text();\n  }\n\n  /**\n   * Gets an error action harness.\n   */\n  public async getErrorAction(): Promise<SkyErrorActionHarness> {\n    const harness = await this.locatorForOptional(SkyErrorActionHarness)();\n\n    if (harness === null) {\n      throw new Error('Unable to find error action.');\n    }\n\n    return harness;\n  }\n\n  /**\n   * Gets an error image harness.\n   */\n  public async getErrorImage(): Promise<SkyErrorImageHarness> {\n    const harness = await this.locatorForOptional(SkyErrorImageHarness)();\n\n    if (harness === null) {\n      throw new Error('Unable to find error image.');\n    }\n\n    return harness;\n  }\n\n  /**\n   * Gets the error type.\n   */\n  public async getErrorType(): Promise<SkyErrorType | undefined> {\n    return ((await (await this.host()).getAttribute('errorType')) ??\n      undefined) as SkyErrorType | undefined;\n  }\n\n  /**\n   * Gets the title of the error.\n   */\n  public async getTitle(): Promise<string> {\n    return await (await this.#title()).text();\n  }\n\n  /**\n   * Whether the error displays an image.\n   */\n  public async hasImage(): Promise<boolean> {\n    return !!(await this.#imageContainer());\n  }\n\n  async #getAction(): Promise<TestElement> {\n    const action = await this.#actionButton();\n\n    if (action === null) {\n      throw Error('Unable to find error action button.');\n    }\n\n    return action;\n  }\n}\n","import { SkyComponentHarness } from '@skyux/core/testing';\n\n/**\n * Harness for interacting with an error modal component in tests.\n * @internal\n */\nexport class SkyErrorModalHarness extends SkyComponentHarness {\n  #closeButton = this.locatorFor('.sky-error-modal-close button');\n  #description = this.locatorFor('.sky-error-modal-description');\n  #title = this.locatorFor('.sky-error-modal-title');\n\n  /**\n   * @internal\n   */\n  public static hostSelector = 'sky-modal:has(.sky-error-modal-container)';\n\n  /**\n   * Gets the title of the error modal.\n   */\n  public async getTitle(): Promise<string> {\n    return await (await this.#title()).text();\n  }\n\n  /**\n   * Gets the description of the error modal.\n   */\n  public async getDescription(): Promise<string> {\n    return await (await this.#description()).text();\n  }\n\n  /**\n   * Gets the text of the error modal close button.\n   */\n  public async getCloseText(): Promise<string> {\n    return await (await this.#closeButton()).text();\n  }\n\n  /**\n   * Clicks the error modal close button.\n   */\n  public async clickCloseButton(): Promise<void> {\n    await (await this.#closeButton()).click();\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAKA,MAAM,yBAAyB,GAAG,yBAAyB;AAE3D;;;;AAIG;MACU,eAAe,CAAA;AAC1B;;AAEG;AACH,IAAA,IAAW,SAAS,GAAA;AAClB,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CACjC,EAAE,CAAC,GAAG,CAAC,kCAAkC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