{"version":3,"file":"ngx-com-components-checkbox-testing.mjs","sources":["../../../projects/com/components/checkbox/testing/checkbox.harness.ts","../../../projects/com/components/checkbox/testing/index.ts","../../../projects/com/components/checkbox/testing/ngx-com-components-checkbox-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 ComCheckboxHarness. */\nexport interface ComCheckboxHarnessFilters extends BaseHarnessFilters {\n  /** Filter by the checkbox's projected label text. */\n  label?: string | RegExp;\n  /** Filter by whether the checkbox is disabled. */\n  disabled?: boolean;\n  /** Filter by whether the checkbox is checked. */\n  checked?: boolean;\n}\n\n/**\n * Harness for interacting with a ComCheckbox in tests.\n */\nexport class ComCheckboxHarness extends ComponentHarness {\n  static hostSelector = 'com-checkbox';\n\n  private readonly label = this.locatorFor('label');\n  private readonly input = this.locatorFor('input[type=\"checkbox\"]');\n  private readonly labelText = this.locatorFor('.com-checkbox__label');\n\n  /**\n   * Gets a HarnessPredicate for matching checkboxes.\n   * @param options Filter options.\n   */\n  static with(options: ComCheckboxHarnessFilters = {}): HarnessPredicate<ComCheckboxHarness> {\n    return new HarnessPredicate(ComCheckboxHarness, 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 checkbox 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 checkbox is disabled. */\n  async isDisabled(): Promise<boolean> {\n    const inputEl = await this.input();\n    return inputEl.getProperty<boolean>('disabled');\n  }\n\n  /** Whether the checkbox is in the indeterminate state. */\n  async isIndeterminate(): Promise<boolean> {\n    const inputEl = await this.input();\n    return inputEl.getProperty<boolean>('indeterminate');\n  }\n\n  /** Whether the checkbox 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 checkbox's projected label text. */\n  async getLabelText(): Promise<string> {\n    const labelEl = await this.labelText();\n    return labelEl.text();\n  }\n\n  /** Gets the checkbox'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 checkbox'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  /** Gets the checkbox's aria-labelledby attribute. */\n  async getAriaLabelledby(): Promise<string | null> {\n    const inputEl = await this.input();\n    return inputEl.getAttribute('aria-labelledby');\n  }\n\n  /** Toggles the checkbox by clicking the label element. */\n  async toggle(): Promise<void> {\n    const labelEl = await this.label();\n    return labelEl.click();\n  }\n\n  /** Checks the checkbox if it is currently unchecked. */\n  async check(): Promise<void> {\n    if (!(await this.isChecked())) {\n      await this.toggle();\n    }\n  }\n\n  /** Unchecks the checkbox 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 checkbox's input element. */\n  async focus(): Promise<void> {\n    const inputEl = await this.input();\n    return inputEl.focus();\n  }\n\n  /** Blurs the checkbox's input element. */\n  async blur(): Promise<void> {\n    const inputEl = await this.input();\n    return inputEl.blur();\n  }\n\n  /** Whether the checkbox'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 checkbox component\n\nexport { ComCheckboxHarness } from './checkbox.harness';\n\nexport type { ComCheckboxHarnessFilters } from './checkbox.harness';\n","/**\n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