{"version":3,"file":"skyux-phone-field-testing.mjs","sources":["../../../../../libs/components/phone-field/testing/src/legacy/phone-field/phone-field-testing.module.ts","../../../../../libs/components/phone-field/testing/src/modules/phone-field/phone-field-input-harness.ts","../../../../../libs/components/phone-field/testing/src/modules/phone-field/phone-field-harness.ts","../../../../../libs/components/phone-field/testing/src/skyux-phone-field-testing.ts"],"sourcesContent":["import { NgModule } from '@angular/core';\nimport { SkyPhoneFieldModule } from '@skyux/phone-field';\n\n/**\n * @internal\n */\n@NgModule({\n  exports: [SkyPhoneFieldModule],\n})\nexport class SkyPhoneFieldTestingModule {}\n","import { SkyInputHarness } from '@skyux/core/testing';\n\n/**\n * Harness to interact with the phone field input harness.\n */\nexport class SkyPhoneFieldInputHarness extends SkyInputHarness {\n  /**\n   * @internal\n   */\n  public static hostSelector = '[skyPhoneFieldInput]';\n}\n","import { HarnessPredicate } from '@angular/cdk/testing';\nimport { SkyComponentHarness } from '@skyux/core/testing';\nimport { SkyCountryFieldHarness } from '@skyux/lookup/testing';\n\nimport { SkyPhoneFieldHarnessFilters } from './phone-field-harness-filters';\nimport { SkyPhoneFieldInputHarness } from './phone-field-input-harness';\n\n/**\n * Harness for interacting with a phone field component in tests.\n */\nexport class SkyPhoneFieldHarness extends SkyComponentHarness {\n  /**\n   * Finds a standard phone field component, or a phone field component that is wrapped by an input box component.\n   * For input box implementations, we need to use the `.sky-input-box` selector since the `sky-country-field`\n   * element is removed from the DOM.\n   * @internal\n   */\n  public static hostSelector = 'sky-phone-field,.sky-input-box';\n\n  #getCountryField = this.locatorForOptional(SkyCountryFieldHarness);\n  #getCountryFieldButton = this.locatorFor(\n    '.sky-phone-field-country-btn button',\n  );\n  #getCountryFieldButtonContainer = this.locatorFor(\n    '.sky-phone-field-country-btn',\n  );\n  #getInput = this.locatorFor(SkyPhoneFieldInputHarness);\n\n  /**\n   * Gets a `HarnessPredicate` that can be used to search for a\n   * `SkyPhoneFieldHarness` that meets certain criteria.\n   *\n   * These filters only work for standalone phone fields. For phone fields\n   * wrapped inside `sky-input-box`, place filters on the input box\n   * instead and query the datepicker using a `SkyInputBoxHarness`.\n   * For the input box implementation, see the code example.\n   */\n  public static with(\n    filters: SkyPhoneFieldHarnessFilters,\n  ): HarnessPredicate<SkyPhoneFieldHarness> {\n    return SkyPhoneFieldHarness.getDataSkyIdPredicate(filters);\n  }\n\n  /**\n   * Gets the phone field input harness.\n   */\n  public async getControl(): Promise<SkyPhoneFieldInputHarness> {\n    return await this.#getInput();\n  }\n\n  /**\n   * Returns the selected country iso2 code.\n   */\n  public async getSelectedCountryIso2(): Promise<string | null> {\n    return await (\n      await this.#getCountryFieldButtonContainer()\n    ).getAttribute('data-sky-test-iso2');\n  }\n\n  /**\n   * Returns the selected country name.\n   */\n  public async getSelectedCountryName(): Promise<string | null> {\n    return await (\n      await this.#getCountryFieldButtonContainer()\n    ).getAttribute('data-sky-test-name');\n  }\n\n  /**\n   * Opens the country selector, performs a search, but makes no selection.\n   * @param searchText The name of the country to select.\n   * @returns The list of country names matching the search text.\n   */\n  public async searchCountry(searchText: string): Promise<string[]> {\n    const countryField = await this.#openCountrySelectionAndSearch(searchText);\n\n    return await countryField.getSearchResultsText();\n  }\n\n  /**\n   * Opens the country selector, performs a search, and selects the first result (if any).\n   * @param searchText The name of the country to select.\n   */\n  public async selectCountry(searchText: string): Promise<void> {\n    const countryField = await this.#openCountrySelectionAndSearch(searchText);\n\n    await countryField.selectSearchResult({});\n  }\n\n  async #openCountrySelectionAndSearch(\n    searchText: string,\n  ): Promise<SkyCountryFieldHarness> {\n    const button = await this.#getCountryFieldButton();\n\n    // Focus the button before clicking to move focus away from the phone input.\n    // Without this, the phone input remains focused when the component toggles\n    // to the country search view, and Angular's @if removal of the focused\n    // input fires a blur event during change detection, causing an\n    // ExpressionChangedAfterItHasBeenCheckedError. In a real browser, clicking\n    // the button naturally moves focus, so this aligns test behavior with\n    // actual user interaction.\n    await button.focus();\n    await button.click();\n\n    const countryField = await this.#getCountryField();\n\n    await countryField?.enterText(searchText);\n\n    return countryField!;\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAGA;;AAEG;MAIU,0BAA0B,CAAA;8GAA1B,0BAA0B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAA1B,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,0BAA0B,YAF3B,mBAAmB,CAAA,EAAA,CAAA,CAAA;AAElB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,0BAA0B,YAF3B,mBAAmB,CAAA,EAAA,CAAA,CAAA;;2FAElB,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBAHtC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,mBAAmB,CAAC;AAC/B,iBAAA;;;ACND;;AAEG;AACG,MAAO,yBAA0B,SAAQ,eAAe,CAAA;AAC5D;;AAEG;aACW,IAAA,CAAA,YAAY,GAAG,sBAAsB,CAAC;;;ACFtD;;AAEG;AACG,MAAO,oBAAqB,SAAQ,mBAAmB,CAAA;AAC3D;;;;;AAKG;aACW,IAAA,CAAA,YAAY,GAAG,gCAAgC,CAAC;AAE9D,IAAA,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,sBAAsB,CAAC;AAClE,IAAA,sBAAsB,GAAG,IAAI,CAAC,UAAU,CACtC,qCAAqC,CACtC;AACD,IAAA,+BAA+B,GAAG,IAAI,CAAC,UAAU,CAC/C,8BAA8B,CAC/B;AACD,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