Skip to content

Commit 875f4ad

Browse files
committed
✅ add more tests to PAGINATION
improves coverage
1 parent 3da9b7b commit 875f4ad

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/pagination/tests/accessibility.test.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import Pagination from '..';
66
/* eslint-disable no-undef */
77
describe('Pagination accessibility tests', () => {
88
let wrappedComponent;
9+
let total = 10;
910

1011
beforeEach(() => {
11-
wrappedComponent = mount(<Pagination total={10} />);
12+
wrappedComponent = mount(<Pagination total={total} />);
1213
});
1314

1415
afterEach(() => {
@@ -23,4 +24,24 @@ describe('Pagination accessibility tests', () => {
2324
wrappedComponent.find('#next-button').simulate('click');
2425
expect(simulatedValue()).to.equal(expectedValueAfterChange);
2526
});
27+
28+
it('Should not change the curentActive page when clicked on itself', () => {
29+
const simulatedValue = () => wrappedComponent.find('div[data-react-active-page="active"]').text();
30+
expect(simulatedValue()).equal('1');
31+
wrappedComponent.find('div[data-react-active-page="active"]').simulate('click');
32+
expect(simulatedValue()).equal('1');
33+
});
34+
35+
it('Should navigate through pages correctly', () => {
36+
const simulatedValue = () => wrappedComponent.find('div[data-react-active-page="active"]').text();
37+
for (let page = 1; page <= total; page += 1) {
38+
expect(Number(simulatedValue())).equal(page);
39+
wrappedComponent.find('#next-button').simulate('click');
40+
}
41+
wrappedComponent.setProps({ defaultActive: total });
42+
for (let page = total; page >= 1; page -= 1) {
43+
expect(Number(simulatedValue())).equal(page);
44+
wrappedComponent.find('#prev-button').simulate('click');
45+
}
46+
});
2647
});

0 commit comments

Comments
 (0)