/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/material/stepper/testing/stepper-button-harnesses.ts
65 строк
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 {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing'; import {StepperButtonHarnessFilters} from './step-harness-filters'; /** Base class for stepper button harnesses. */ abstract class StepperButtonHarness extends ComponentHarness { /** Gets the text of the button. */ async getText(): Promise<string> { return (await this.host()).text(); } /** Clicks the button. */ async click(): Promise<void> { return (await this.host()).click(); } } /** Harness for interacting with a standard Angular Material stepper next button in tests. */ export class MatStepperNextHarness extends StepperButtonHarness { /** The selector for the host element of a `MatStep` instance. */ static hostSelector = '.mat-stepper-next'; /** * Gets a `HarnessPredicate` that can be used to search for a `MatStepperNextHarness` that meets * certain criteria. * @param options Options for filtering which steps are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options: StepperButtonHarnessFilters = {}): HarnessPredicate<MatStepperNextHarness> { return new HarnessPredicate(MatStepperNextHarness, options).addOption( 'text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text), ); } } /** Harness for interacting with a standard Angular Material stepper previous button in tests. */ export class MatStepperPreviousHarness extends StepperButtonHarness { /** The selector for the host element of a `MatStep` instance. */ static hostSelector = '.mat-stepper-previous'; /** * Gets a `HarnessPredicate` that can be used to search for a `MatStepperPreviousHarness` * that meets certain criteria. * @param options Options for filtering which steps are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with( options: StepperButtonHarnessFilters = {}, ): HarnessPredicate<MatStepperPreviousHarness> { return new HarnessPredicate(MatStepperPreviousHarness, options).addOption( 'text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text), ); } }