/** * @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 { MatLegacyChipHarness } from './chip-harness'; /** * @deprecated Use `MatChipOptionHarness` from `@angular/material/chips/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacyChipOptionHarness extends MatLegacyChipHarness { /** The selector for the host element of a selectable chip instance. */ static { this.hostSelector = '.mat-chip'; } /** * Gets a `HarnessPredicate` that can be used to search for a `MatChipOptionHarness` * that meets certain criteria. * @param options Options for filtering which chip instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(MatLegacyChipOptionHarness, options) .addOption('text', options.text, (harness, label) => HarnessPredicate.stringMatches(harness.getText(), label)) .addOption('selected', options.selected, async (harness, selected) => (await harness.isSelected()) === selected); } /** Whether the chip is selected. */ async isSelected() { return (await this.host()).hasClass('mat-chip-selected'); } /** Selects the given chip. Only applies if it's selectable. */ async select() { if (!(await this.isSelected())) { await this.toggle(); } } /** Deselects the given chip. Only applies if it's selectable. */ async deselect() { if (await this.isSelected()) { await this.toggle(); } } /** Toggles the selected state of the given chip. */ async toggle() { return (await this.host()).sendKeys(' '); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpcC1vcHRpb24taGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9sZWdhY3ktY2hpcHMvdGVzdGluZy9jaGlwLW9wdGlvbi1oYXJuZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxnQkFBZ0IsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sRUFBQyxvQkFBb0I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