Skip to content

Commit

Permalink
feat: p-password harness (#254)
Browse files Browse the repository at this point in the history
* feat: p-password harness added

* fix: export harness
  • Loading branch information
markuczy authored May 15, 2024
1 parent 802bf5a commit 32ac035
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/angular-testing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PPasswordHarness> {
return new HarnessPredicate(PPasswordHarness, options).addOption('id', options.id, (harness, id) =>
HarnessPredicate.stringMatches(harness.getId(), id)
)
}
async getId(): Promise<string | null> {
return await (await this.host()).getAttribute('id')
}

async getPromptLabel(): Promise<string | null> {
return await (await this.host()).getAttribute('ng-reflect-prompt-label')
}

async getWeakLabel(): Promise<string | null> {
return await (await this.host()).getAttribute('ng-reflect-weak-label')
}

async getMediumLabel(): Promise<string | null> {
return await (await this.host()).getAttribute('ng-reflect-medium-label')
}

async getStrongLabel(): Promise<string | null> {
return await (await this.host()).getAttribute('ng-reflect-strong-label')
}

async getValue(): Promise<string | null> {
return await (await this.getInput()).getValue()
}

async setValue(value: string) {
return await (await this.getInput()).setValue(value)
}
}

0 comments on commit 32ac035

Please sign in to comment.