{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/checkbox/testing/checkbox-harness.ts","../../../../../../../src/material/checkbox/testing/checkbox-harness-filters.ts","../../../../../../../src/material/checkbox/testing/public-api.ts","../../../../../../../src/material/checkbox/testing/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {coerceBooleanProperty} from '@angular/cdk/coercion';\nimport {\n  AsyncFactoryFn,\n  ComponentHarness,\n  HarnessPredicate,\n  TestElement,\n} from '@angular/cdk/testing';\nimport {CheckboxHarnessFilters} from './checkbox-harness-filters';\n\nexport abstract class _MatCheckboxHarnessBase extends ComponentHarness {\n  protected abstract _input: AsyncFactoryFn<TestElement>;\n  protected abstract _label: AsyncFactoryFn<TestElement>;\n\n  /** Whether the checkbox is checked. */\n  async isChecked(): Promise<boolean> {\n    const checked = (await this._input()).getProperty<boolean>('checked');\n    return coerceBooleanProperty(await checked);\n  }\n\n  /** Whether the checkbox is in an indeterminate state. */\n  async isIndeterminate(): Promise<boolean> {\n    const indeterminate = (await this._input()).getProperty<string>('indeterminate');\n    return coerceBooleanProperty(await indeterminate);\n  }\n\n  /** Whether the checkbox is disabled. */\n  async isDisabled(): Promise<boolean> {\n    const disabled = (await this._input()).getAttribute('disabled');\n    return coerceBooleanProperty(await disabled);\n  }\n\n  /** Whether the checkbox is required. */\n  async isRequired(): Promise<boolean> {\n    const required = (await this._input()).getProperty<boolean>('required');\n    return coerceBooleanProperty(await required);\n  }\n\n  /** Whether the checkbox is valid. */\n  async isValid(): Promise<boolean> {\n    const invalid = (await this.host()).hasClass('ng-invalid');\n    return !(await invalid);\n  }\n\n  /** Gets the checkbox's name. */\n  async getName(): Promise<string|null> {\n    return (await this._input()).getAttribute('name');\n  }\n\n  /** Gets the checkbox's value. */\n  async getValue(): Promise<string|null> {\n    return (await this._input()).getProperty<string|null>('value');\n  }\n\n  /** Gets the checkbox's aria-label. */\n  async getAriaLabel(): Promise<string|null> {\n    return (await this._input()).getAttribute('aria-label');\n  }\n\n  /** Gets the checkbox's aria-labelledby. */\n  async getAriaLabelledby(): Promise<string|null> {\n    return (await this._input()).getAttribute('aria-labelledby');\n  }\n\n  /** Gets the checkbox's label text. */\n  async getLabelText(): Promise<string> {\n    return (await this._label()).text();\n  }\n\n  /** Focuses the checkbox. */\n  async focus(): Promise<void> {\n    return (await this._input()).focus();\n  }\n\n  /** Blurs the checkbox. */\n  async blur(): Promise<void> {\n    return (await this._input()).blur();\n  }\n\n  /** Whether the checkbox is focused. */\n  async isFocused(): Promise<boolean> {\n    return (await this._input()).isFocused();\n  }\n\n  /**\n   * Toggles the checked state of the checkbox.\n   *\n   * Note: This attempts to toggle the checkbox as a user would, by clicking it. Therefore if you\n   * are using `MAT_CHECKBOX_DEFAULT_OPTIONS` to change the behavior on click, calling this method\n   * might not have the expected result.\n   */\n  abstract toggle(): Promise<void>;\n\n  /**\n   * Puts the checkbox in a checked state by toggling it if it is currently unchecked, or doing\n   * nothing if it is already checked.\n   *\n   * Note: This attempts to check the checkbox as a user would, by clicking it. Therefore if you\n   * are using `MAT_CHECKBOX_DEFAULT_OPTIONS` to change the behavior on click, calling this method\n   * might not have the expected result.\n   */\n  async check(): Promise<void> {\n    if (!(await this.isChecked())) {\n      await this.toggle();\n    }\n  }\n\n  /**\n   * Puts the checkbox in an unchecked state by toggling it if it is currently checked, or doing\n   * nothing if it is already unchecked.\n   *\n   * Note: This attempts to uncheck the checkbox as a user would, by clicking it. Therefore if you\n   * are using `MAT_CHECKBOX_DEFAULT_OPTIONS` to change the behavior on click, calling this method\n   * might not have the expected result.\n   */\n  async uncheck(): Promise<void> {\n    if (await this.isChecked()) {\n      await this.toggle();\n    }\n  }\n}\n\n/** Harness for interacting with a standard mat-checkbox in tests. */\nexport class MatCheckboxHarness extends _MatCheckboxHarnessBase {\n  /** The selector for the host element of a `MatCheckbox` instance. */\n  static hostSelector = '.mat-checkbox';\n\n  /**\n   * Gets a `HarnessPredicate` that can be used to search for a `MatCheckboxHarness` that meets\n   * certain criteria.\n   * @param options Options for filtering which checkbox instances are considered a match.\n   * @return a `HarnessPredicate` configured with the given options.\n   */\n  static with(options: CheckboxHarnessFilters = {}): HarnessPredicate<MatCheckboxHarness> {\n    return new HarnessPredicate(MatCheckboxHarness, options)\n        .addOption(\n            'label', options.label,\n            (harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label))\n        // We want to provide a filter option for \"name\" because the name of the checkbox is\n        // only set on the underlying input. This means that it's not possible for developers\n        // to retrieve the harness of a specific checkbox with name through a CSS selector.\n        .addOption('name', options.name, async (harness, name) => await harness.getName() === name);\n  }\n\n  protected _input = this.locatorFor('input');\n  protected _label = this.locatorFor('.mat-checkbox-label');\n  private _inputContainer = this.locatorFor('.mat-checkbox-inner-container');\n\n  async toggle(): Promise<void> {\n    return (await this._inputContainer()).click();\n  }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {BaseHarnessFilters} from '@angular/cdk/testing';\n\n/** A set of criteria that can be used to filter a list of `MatCheckboxHarness` instances. */\nexport interface CheckboxHarnessFilters extends BaseHarnessFilters {\n  /** Only find instances whose label matches the given value. */\n  label?: string | RegExp;\n  /** Only find instances whose name attribute is the given value. */\n  name?: string;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './checkbox-harness';\nexport * from './checkbox-harness-filters';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;;;;;MAiBsB,uBAAwB,SAAQ,gBAAgB;;IAKpE,MAAM,SAAS;QACb,MAAM,O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