/** * @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 { ComponentHarness, HarnessPredicate, parallel } from '@angular/cdk/testing'; import { MatLegacyChipHarness } from './chip-harness'; import { MatLegacyChipInputHarness } from './chip-input-harness'; /** * Base class for chip list harnesses. * @deprecated Use `class` 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 _MatChipListHarnessBase extends ComponentHarness { /** Gets whether the chip list is disabled. */ async isDisabled() { return (await (await this.host()).getAttribute('aria-disabled')) === 'true'; } /** Gets whether the chip list is required. */ async isRequired() { return (await (await this.host()).getAttribute('aria-required')) === 'true'; } /** Gets whether the chip list is invalid. */ async isInvalid() { return (await (await this.host()).getAttribute('aria-invalid')) === 'true'; } /** Gets whether the chip list is in multi selection mode. */ async isMultiple() { return (await (await this.host()).getAttribute('aria-multiselectable')) === 'true'; } /** Gets whether the orientation of the chip list. */ async getOrientation() { const orientation = await (await this.host()).getAttribute('aria-orientation'); return orientation === 'vertical' ? 'vertical' : 'horizontal'; } } /** * Harness for interacting with a standard chip list in tests. * @deprecated Use `MatChipListHarness` 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 MatLegacyChipListHarness 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(MatLegacyChipListHarness, options); } /** * Gets the list of chips inside the chip list. * @param filter Optionally filters which chips are included. */ async getChips(filter = {}) { return this.locatorForAll(MatLegacyChipHarness.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. * @deprecated Use `MatChipListboxHarness.selectChips` instead. * @breaking-change 12.0.0 */ 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())); } /** * Gets the `MatChipInput` inside the chip list. * @param filter Optionally filters which chip input is included. */ async getInput(filter = {}) { // The input isn't required to be a descendant of the chip list so we have to look it up by id. const inputId = await (await this.host()).getAttribute('data-mat-chip-input'); if (!inputId) { throw Error(`Chip list is not associated with an input`); } return this.documentRootLocatorFactory().locatorFor(MatLegacyChipInputHarness.with({ ...filter, selector: `#${inputId}` }))(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpcC1saXN0LWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvbGVnYWN5LWNoaXBzL3Rlc3RpbmcvY2hpcC1saXN0LWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGdCQUFnQixFQUFFLGdCQUFnQixFQUFFLFFBQVEsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBQ2xGLE9BQU8sRUFBQyxvQkFBb0IsRUFBQyxNQUFNLGdCQUFnQixDQUFDO0FBQ3BELE9BQU8sRUFBQyx5QkFBeUIsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBTy9EOzs7O0dBSUc7QUFDSCxNQUFNLE9BQWdCLHVCQUF3QixTQUFRLGdCQUFnQjtJQUNwRSw4Q0FBOEM7SUFDOUMsS0FBSyxDQUFDLFVBQVU7UUFDZCxPQUFPLENBQUMsTUFBTSxDQUFDLE1BQU0sSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDLENBQUMsWUFBWSxDQUFDLGVBQWUsQ0FBQyxDQUFDLEtBQUssTUFBTSxDQUFDO0lBQ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