{"version":3,"file":"ngx-com-components-switch-testing.mjs","sources":["../../../projects/com/components/switch/testing/switch.harness.ts","../../../projects/com/components/switch/testing/index.ts","../../../projects/com/components/switch/testing/ngx-com-components-switch-testing.ts"],"sourcesContent":["import {\n  ComponentHarness,\n  HarnessPredicate,\n} from '@angular/cdk/testing';\nimport type { BaseHarnessFilters } from '@angular/cdk/testing';\n\n/** Harness filters for ComSwitchHarness. */\nexport interface ComSwitchHarnessFilters extends BaseHarnessFilters {\n  /** Filter by the switch's label text. */\n  label?: string | RegExp;\n  /** Filter by whether the switch is disabled. */\n  disabled?: boolean;\n  /** Filter by whether the switch is checked. */\n  checked?: boolean;\n}\n\n/**\n * Harness for interacting with a ComSwitch in tests.\n */\nexport class ComSwitchHarness extends ComponentHarness {\n  static hostSelector = 'com-switch';\n\n  private readonly label = this.locatorFor('label');\n  private readonly input = this.locatorFor('input[type=\"checkbox\"][role=\"switch\"]');\n  private readonly labelText = this.locatorFor('.com-switch__label');\n\n  /**\n   * Gets a HarnessPredicate for matching switches.\n   * @param options Filter options.\n   */\n  static with(options: ComSwitchHarnessFilters = {}): HarnessPredicate<ComSwitchHarness> {\n    return new HarnessPredicate(ComSwitchHarness, options)\n      .addOption('label', options.label, async (harness, label) => {\n        const text = await harness.getLabelText();\n        return HarnessPredicate.stringMatches(text, label);\n      })\n      .addOption('disabled', options.disabled, async (harness, disabled) => {\n        return (await harness.isDisabled()) === disabled;\n      })\n      .addOption('checked', options.checked, async (harness, checked) => {\n        return (await harness.isChecked()) === checked;\n      });\n  }\n\n  /** Whether the switch is currently checked. */\n  async isChecked(): Promise<boolean> {\n    const inputEl = await this.input();\n    return inputEl.getProperty<boolean>('checked');\n  }\n\n  /** Whether the switch is disabled. */\n  async isDisabled(): Promise<boolean> {\n    const inputEl = await this.input();\n    return inputEl.getProperty<boolean>('disabled');\n  }\n\n  /** Whether the switch is required. */\n  async isRequired(): Promise<boolean> {\n    const inputEl = await this.input();\n    const ariaRequired = await inputEl.getAttribute('aria-required');\n    if (ariaRequired !== null) {\n      return ariaRequired === 'true';\n    }\n    return inputEl.getProperty<boolean>('required');\n  }\n\n  /** Gets the switch's label text. */\n  async getLabelText(): Promise<string> {\n    const labelEl = await this.labelText();\n    return labelEl.text();\n  }\n\n  /** Gets the switch's name attribute. */\n  async getName(): Promise<string | null> {\n    const inputEl = await this.input();\n    return inputEl.getAttribute('name');\n  }\n\n  /** Gets the switch's aria-label attribute. */\n  async getAriaLabel(): Promise<string | null> {\n    const inputEl = await this.input();\n    return inputEl.getAttribute('aria-label');\n  }\n\n  /** Toggles the switch by clicking its label. */\n  async toggle(): Promise<void> {\n    const labelEl = await this.label();\n    return labelEl.click();\n  }\n\n  /** Checks the switch if it is not already checked. */\n  async check(): Promise<void> {\n    if (!(await this.isChecked())) {\n      await this.toggle();\n    }\n  }\n\n  /** Unchecks the switch if it is currently checked. */\n  async uncheck(): Promise<void> {\n    if (await this.isChecked()) {\n      await this.toggle();\n    }\n  }\n\n  /** Focuses the switch's input element. */\n  async focus(): Promise<void> {\n    const inputEl = await this.input();\n    return inputEl.focus();\n  }\n\n  /** Blurs the switch's input element. */\n  async blur(): Promise<void> {\n    const inputEl = await this.input();\n    return inputEl.blur();\n  }\n\n  /** Whether the switch's input element is focused. */\n  async isFocused(): Promise<boolean> {\n    const inputEl = await this.input();\n    return inputEl.isFocused();\n  }\n}\n","// Testing utilities for the switch component\n\nexport { ComSwitchHarness } from './switch.harness';\n\nexport type { ComSwitchHarnessFilters } from './switch.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAgBA;;AAEG;AACG,MAAO,gBAAiB,SAAQ,gBAAgB,CAAA;AACpD,IAAA,OAAO,YAAY,GAAG,YAAY;AAEjB,IAAA,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;AAChC,IAAA,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,uCAAuC,CAAC;AAChE,IAAA,SAAS,GAAG,IA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