Skip to content

Commit 69666cf

Browse files
committed
don't rely on internal property in tests
1 parent bf04970 commit 69666cf

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

packages/uui-pagination/lib/uui-pagination.test.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
html,
3-
fixture,
4-
expect,
5-
waitUntil,
6-
elementUpdated,
7-
} from '@open-wc/testing';
1+
import { html, fixture, expect, elementUpdated } from '@open-wc/testing';
82
import { UUIPaginationElement } from './uui-pagination.element';
93
import '.';
104

@@ -31,17 +25,14 @@ describe('UUIPaginationElement', () => {
3125
// });
3226

3327
it('sets active class on current page', async () => {
34-
await waitUntil(() => element.visiblePages.length > 1);
3528
element.current = 2;
29+
await elementUpdated(element);
3630
const button = element.shadowRoot?.querySelector('#group')!
3731
.children[3] as HTMLElement;
38-
await elementUpdated(button);
39-
4032
expect(button).to.have.class('active-button');
4133
});
4234

4335
it('goes to selected page on click', async () => {
44-
await waitUntil(() => element.visiblePages.length > 1);
4536
const button = element.shadowRoot?.querySelector('#group')!
4637
.children[3] as HTMLElement;
4738
button.click();
@@ -53,8 +44,9 @@ describe('UUIPaginationElement', () => {
5344
});
5445

5546
it('goes to previous page on click', async () => {
56-
await waitUntil(() => element.visiblePages.length > 1);
5747
element.current = 2;
48+
await elementUpdated(element);
49+
5850
const buttons = element.shadowRoot?.querySelector('#group')!.children;
5951
const prevButton = buttons![1] as HTMLElement;
6052
const activeButton = buttons![2] as HTMLElement;
@@ -67,21 +59,19 @@ describe('UUIPaginationElement', () => {
6759
});
6860

6961
it('goes to next page on click', async () => {
70-
await waitUntil(() => element.visiblePages.length > 1);
7162
element.current = 2;
63+
await elementUpdated(element);
64+
7265
const buttons = element.shadowRoot?.querySelector('#group')?.children;
7366
const nextButton = buttons![6] as HTMLElement;
7467
const activeButton = buttons![3] as HTMLElement;
7568
nextButton.click();
7669

77-
await elementUpdated(element);
78-
7970
expect(element.current).to.equal(3);
8071
expect(activeButton).to.have.class('active-button');
8172
});
8273

8374
it('goes to last page on click and disables last and next buttons', async () => {
84-
await waitUntil(() => element.visiblePages.length > 1);
8575
let buttons = element.shadowRoot?.querySelector('#group')?.children;
8676
const lastButton = buttons![7] as HTMLElement;
8777
const nextButton = buttons![6] as HTMLElement;
@@ -99,16 +89,16 @@ describe('UUIPaginationElement', () => {
9989
});
10090

10191
it('goes to first page on click and disables first and previous buttons', async () => {
102-
await waitUntil(() => element.visiblePages.length > 1);
10392
element.current = 3;
93+
await elementUpdated(element);
94+
10495
const buttons = element.shadowRoot?.querySelector('#group')?.children;
10596
const firstButton = buttons![0] as HTMLElement;
10697
const previousButton = buttons![1] as HTMLElement;
107-
const activeButton = buttons![2] as HTMLElement;
10898
firstButton.click();
109-
11099
await elementUpdated(element);
111100

101+
const activeButton = buttons![2] as HTMLElement;
112102
expect(element.current).to.equal(1);
113103
expect(activeButton).to.have.class('active-button');
114104
expect(firstButton).to.have.attribute('disabled');

0 commit comments

Comments
 (0)