From 32ac035ab16f58c7aca9089325c00c13501a63b9 Mon Sep 17 00:00:00 2001 From: markuczy <129275100+markuczy@users.noreply.github.com> Date: Wed, 15 May 2024 14:42:09 +0200 Subject: [PATCH] feat: p-password harness (#254) * feat: p-password harness added * fix: export harness --- libs/angular-testing/src/index.ts | 1 + .../harnesses/primeng/p-password.harness.ts | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 libs/angular-testing/src/lib/harnesses/primeng/p-password.harness.ts diff --git a/libs/angular-testing/src/index.ts b/libs/angular-testing/src/index.ts index bcda0e94..1a2b7edf 100644 --- a/libs/angular-testing/src/index.ts +++ b/libs/angular-testing/src/index.ts @@ -8,6 +8,7 @@ export * from './lib/harnesses/primeng/p-dropdown.harness' export * from './lib/harnesses/primeng/p-menu.harness' export * from './lib/harnesses/primeng/p-multiSelect.harness' export * from './lib/harnesses/primeng/p-multiSelectListItem.harness' +export * from './lib/harnesses/primeng/p-password.harness' export * from './lib/harnesses/primeng/p-picklist.harness' export * from './lib/harnesses/primeng/p-selectButton.harness' export * from './lib/harnesses/primeng/p-paginator.harness' diff --git a/libs/angular-testing/src/lib/harnesses/primeng/p-password.harness.ts b/libs/angular-testing/src/lib/harnesses/primeng/p-password.harness.ts new file mode 100644 index 00000000..f94513cc --- /dev/null +++ b/libs/angular-testing/src/lib/harnesses/primeng/p-password.harness.ts @@ -0,0 +1,45 @@ +import { BaseHarnessFilters, ComponentHarness, HarnessPredicate } from '@angular/cdk/testing' +import { InputHarness } from '../input.harness' + +export interface PPasswordHarnessFilters extends BaseHarnessFilters { + id?: string +} + +export class PPasswordHarness extends ComponentHarness { + static hostSelector = 'p-password' + + getInput = this.locatorFor(InputHarness) + + static with(options: PPasswordHarnessFilters): HarnessPredicate { + return new HarnessPredicate(PPasswordHarness, options).addOption('id', options.id, (harness, id) => + HarnessPredicate.stringMatches(harness.getId(), id) + ) + } + async getId(): Promise { + return await (await this.host()).getAttribute('id') + } + + async getPromptLabel(): Promise { + return await (await this.host()).getAttribute('ng-reflect-prompt-label') + } + + async getWeakLabel(): Promise { + return await (await this.host()).getAttribute('ng-reflect-weak-label') + } + + async getMediumLabel(): Promise { + return await (await this.host()).getAttribute('ng-reflect-medium-label') + } + + async getStrongLabel(): Promise { + return await (await this.host()).getAttribute('ng-reflect-strong-label') + } + + async getValue(): Promise { + return await (await this.getInput()).getValue() + } + + async setValue(value: string) { + return await (await this.getInput()).setValue(value) + } +}