/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { HarnessPredicate } from '@angular/cdk/testing'; import { _MatCheckboxHarnessBase } from '@angular/material/checkbox/testing'; /** * Harness for interacting with a standard mat-checkbox in tests. * @deprecated Use `MatCheckboxHarness` from `@angular/material/checkbox/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacyCheckboxHarness extends _MatCheckboxHarnessBase { constructor() { super(...arguments); this._input = this.locatorFor('input'); this._label = this.locatorFor('.mat-checkbox-label'); this._inputContainer = this.locatorFor('.mat-checkbox-inner-container'); } /** The selector for the host element of a checkbox instance. */ static { this.hostSelector = '.mat-checkbox'; } /** * Gets a `HarnessPredicate` that can be used to search for a checkbox harness that meets * certain criteria. * @param options Options for filtering which checkbox instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return (new HarnessPredicate(MatLegacyCheckboxHarness, options) .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label)) // We want to provide a filter option for "name" because the name of the checkbox is // only set on the underlying input. This means that it's not possible for developers // to retrieve the harness of a specific checkbox with name through a CSS selector. .addOption('name', options.name, async (harness, name) => (await harness.getName()) === name) .addOption('checked', options.checked, async (harness, checked) => (await harness.isChecked()) == checked) .addOption('disabled', options.disabled, async (harness, disabled) => { return (await harness.isDisabled()) === disabled; })); } async toggle() { return (await this._inputContainer()).click(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2tib3gtaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9sZWdhY3ktY2hlY2tib3gvdGVzdGluZy9jaGVja2JveC1oYXJuZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7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