/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/material/chips/testing/chip-row-harness.ts
47 строк
2 KB
Naji
docs: replace angular.io links with angular.dev (#29734)
19 сен 2024, 13:57
Не верифицирован
19 сен 2024, 13:57
5782834
Код
Авторство
О чём код?
/** * @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.dev/license */ import {TestKey} from '@angular/cdk/testing'; import {MatChipEditInputHarness} from './chip-edit-input-harness'; import {MatChipHarness} from './chip-harness'; import {ChipEditInputHarnessFilters} from './chip-harness-filters'; /** Harness for interacting with a mat-chip-row in tests. */ export class MatChipRowHarness extends MatChipHarness { static override hostSelector = '.mat-mdc-chip-row'; /** Whether the chip is editable. */ async isEditable(): Promise<boolean> { return (await this.host()).hasClass('mat-mdc-chip-editable'); } /** Whether the chip is currently being edited. */ async isEditing(): Promise<boolean> { return (await this.host()).hasClass('mat-mdc-chip-editing'); } /** Sets the chip row into an editing state, if it is editable. */ async startEditing(): Promise<void> { 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(): Promise<void> { if (await this.isEditing()) { await (await this.host()).sendKeys(TestKey.ENTER); } } /** Gets the edit input inside the chip row. */ async getEditInput(filter: ChipEditInputHarnessFilters = {}): Promise<MatChipEditInputHarness> { return this.locatorFor(MatChipEditInputHarness.with(filter))(); } }