/** * @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, } from '@angular/cdk/testing'; import { MatChipInputHarness } from './chip-input-harness'; import { MatChipRowHarness } from './chip-row-harness'; /** Harness for interacting with a mat-chip-grid in tests. */ export class MatChipGridHarness extends ComponentHarness { static { this.hostSelector = '.mat-mdc-chip-grid'; } /** * Gets a `HarnessPredicate` that can be used to search for a chip grid with specific attributes. * @param options Options for filtering which chip grid instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(this, options).addOption('disabled', options.disabled, async (harness, disabled) => { return (await harness.isDisabled()) === disabled; }); } /** Gets whether the chip grid is disabled. */ async isDisabled() { return (await (await this.host()).getAttribute('aria-disabled')) === 'true'; } /** Gets whether the chip grid is required. */ async isRequired() { return await (await this.host()).hasClass('mat-mdc-chip-list-required'); } /** Gets whether the chip grid is invalid. */ async isInvalid() { return (await (await this.host()).getAttribute('aria-invalid')) === 'true'; } /** Gets promise of the harnesses for the chip rows. */ getRows(filter = {}) { return this.locatorForAll(MatChipRowHarness.with(filter))(); } /** Gets promise of the chip text input harness. */ getInput(filter = {}) { return this.locatorFor(MatChipInputHarness.with(filter))(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpcC1ncmlkLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvY2hpcHMvdGVzdGluZy9jaGlwLWdyaWQtaGFybmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQ0wsZ0JBQWdCLEVBRWhCLGdCQUFnQixHQUNqQixNQUFNLHNCQUFzQixDQUFDO0FBTTlCLE9BQU8sRUFBQyxtQkFBbUIsRUFB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