Skip to content

Commit

Permalink
refactor(testing): improve flexibility of TuiNativeInputPO (#7574)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbarsukov authored May 30, 2024
1 parent 06fa5eb commit 582625f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,17 @@ describe('InputRange', () => {

inputPOLeft = new TuiNativeInputPO(
fixture,
testContext.nativeInputAutoId,
leftInputWrapper,
pageObject.getByAutomationId(
testContext.nativeInputAutoId,
leftInputWrapper,
)!,
);
inputPORight = new TuiNativeInputPO(
fixture,
testContext.nativeInputAutoId,
rightInputWrapper,
pageObject.getByAutomationId(
testContext.nativeInputAutoId,
rightInputWrapper,
)!,
);
}
});
10 changes: 4 additions & 6 deletions projects/testing/utils/native-input.page-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ export class TuiNativeInputPO {

constructor(
private readonly fixture: ComponentFixture<unknown>,
private readonly automationId: string,
private readonly hostDebugElement?: DebugElement,
private readonly automationIdOrElement: DebugElement | string,
) {
this.pageObject = new TuiPageObject(fixture);
}

public get nativeElement(): HTMLInputElement | HTMLTextAreaElement | null {
return (
this.pageObject.getByAutomationId(this.automationId, this.hostDebugElement)
?.nativeElement ?? null
);
return typeof this.automationIdOrElement === 'string'
? this.pageObject.getByAutomationId(this.automationIdOrElement)?.nativeElement
: this.automationIdOrElement.nativeElement;
}

public get value(): string {
Expand Down

0 comments on commit 582625f

Please sign in to comment.