/** * @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, parallel } from '@angular/cdk/testing'; import { MatLegacyChipOptionHarness } from './chip-option-harness'; import { _MatChipListHarnessBase } from './chip-list-harness'; /** * Harness for interacting with a standard selectable chip list in tests. * @deprecated Use `MatChipListboxHarness` 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 MatLegacyChipListboxHarness extends _MatChipListHarnessBase { /** The selector for the host element of a `MatChipList` instance. */ static { this.hostSelector = '.mat-chip-list'; } /** * Gets a `HarnessPredicate` that can be used to search for a `MatChipListHarness` that meets * certain criteria. * @param options Options for filtering which chip list instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(MatLegacyChipListboxHarness, options); } /** * Gets the list of chips inside the chip list. * @param filter Optionally filters which chips are included. */ async getChips(filter = {}) { return this.locatorForAll(MatLegacyChipOptionHarness.with(filter))(); } /** * Selects a chip inside the chip list. * @param filter An optional filter to apply to the child chips. * All the chips matching the filter will be selected. */ async selectChips(filter = {}) { const chips = await this.getChips(filter); if (!chips.length) { throw Error(`Cannot find chip matching filter ${JSON.stringify(filter)}`); } await parallel(() => chips.map(chip => chip.select())); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpcC1saXN0Ym94LWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvbGVnYWN5LWNoaXBzL3Rlc3RpbmcvY2hpcC1saXN0Ym94LWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGdCQUFnQixFQUFFLFFBQVEsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0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