/** * @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 { TestKey } from '@angular/cdk/testing'; import { MatChipEditInputHarness } from './chip-edit-input-harness'; import { MatChipHarness } from './chip-harness'; /** Harness for interacting with a mat-chip-row in tests. */ export class MatChipRowHarness extends MatChipHarness { static { this.hostSelector = '.mat-mdc-chip-row'; } /** Whether the chip is editable. */ async isEditable() { return (await this.host()).hasClass('mat-mdc-chip-editable'); } /** Whether the chip is currently being edited. */ async isEditing() { return (await this.host()).hasClass('mat-mdc-chip-editing'); } /** Sets the chip row into an editing state, if it is editable. */ async startEditing() { if (!(await this.isEditable())) { throw new Error('Cannot begin editing a chip that is not editable.'); } return (await this.host()).dispatchEvent('dblclick'); } /** Stops editing the chip, if it was in the editing state. */ async finishEditing() { if (await this.isEditing()) { await (await this.host()).sendKeys(TestKey.ENTER); } } /** Gets the edit input inside the chip row. */ async getEditInput(filter = {}) { return this.locatorFor(MatChipEditInputHarness.with(filter))(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpcC1yb3ctaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9jaGlwcy90ZXN0aW5nL2NoaXAtcm93LWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLE9BQU8sRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBQzdDLE9BQU8sRUFBQyx1QkFBdUIsRUFBQyxNQUFNLDJCQUEyQixDQUFDO0FBQ2xFLE9BQU8sRUFBQyxjQUFjLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUc5Qyw0REFBNEQ7QUFDNUQsTUFBTSxPQUFPLGlCQUFrQixTQUFRLGNBQWM7YUFDbkM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