Skip to content

Commit

Permalink
chore: Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Dani committed Jan 27, 2025
1 parent 13536da commit ea32eb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/fixtures/test-page-object.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<div id="scrollable-container" style="overflow: auto; max-height: 30px">
<div style="width: 120%; height: 100px">Some scrollable text</div>
</div>
<div id="vertically-scrollable-container" style="overflow-y: scroll; overflow-x: hidden; max-height: 30px">
<div style="height: 100px; width: 100px;">Some scrollable text to layout vertically in a container</div>
</div>
<button id="button">Click me</button>
<button id="update-live-announcement-button">Update live announcement</button>
<div aria-live="polite" id="live-announcement"></div>
Expand Down
10 changes: 9 additions & 1 deletion test/page-object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,22 @@ test(
);

test(
'elementScrollTo should scroll when trying to scroll a non-scrollable element',
'elementScrollTo should not scroll when trying to scroll a non-scrollable element',
setupTest(async page => {
await expect(() => page.elementScrollTo('#text-content', { left: 40 })).rejects.toThrowError(
/Element #text-content is not scrollable/
);
})
);

test(
'elementScrollTo should scroll when one direction is scrollable',
setupTest(async page => {
await page.elementScrollTo('#vertically-scrollable-container', { top: 40 });
expect(await page.getElementScroll('#vertically-scrollable-container')).toEqual({ top: 40, left: 0 });
})
);

test(
'scrollToRight',
setupTest(async page => {
Expand Down

0 comments on commit ea32eb9

Please sign in to comment.