Skip to content

Commit 8d222ad

Browse files
francoischalifourHaroenv
authored andcommitted
fix(pagination): update no refinement behavior (#4124)
1 parent 535f725 commit 8d222ad

File tree

3 files changed

+129
-3
lines changed

3 files changed

+129
-3
lines changed

src/components/Pagination/Pagination.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Pagination extends Component {
113113
return (
114114
<div
115115
className={cx(this.props.cssClasses.root, {
116-
[this.props.cssClasses.noRefinementRoot]: this.props.isFirstPage,
116+
[this.props.cssClasses.noRefinementRoot]: this.props.nbPages <= 1,
117117
})}
118118
>
119119
<ul className={this.props.cssClasses.list}>

src/components/Pagination/__tests__/Pagination-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ describe('Pagination', () => {
4545
it('should display the first/last link', () => {
4646
const wrapper = mount(<Pagination {...defaultProps} showFirst showLast />);
4747

48+
expect(wrapper.find('.firstPageItem')).toHaveLength(1);
49+
expect(wrapper.find('.lastPageItem')).toHaveLength(1);
50+
expect(wrapper).toMatchSnapshot();
51+
});
52+
53+
it('should add the noRefinement CSS class with a single page', () => {
54+
const wrapper = mount(<Pagination {...defaultProps} nbPages={1} />);
55+
56+
expect(wrapper.find('.noRefinementRoot')).toHaveLength(1);
4857
expect(wrapper).toMatchSnapshot();
4958
});
5059

@@ -63,6 +72,7 @@ describe('Pagination', () => {
6372
/>
6473
);
6574

75+
expect(wrapper.find('.lastPageItem').hasClass('disabledItem')).toBe(true);
6676
expect(wrapper).toMatchSnapshot();
6777
});
6878

src/components/Pagination/__tests__/__snapshots__/Pagination-test.js.snap

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,121 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Pagination should add the noRefinement CSS class with a single page 1`] = `
4+
<div
5+
className="root noRefinementRoot"
6+
>
7+
<ul
8+
className="list"
9+
>
10+
<li
11+
className="item pageItem selectedItem"
12+
>
13+
<a
14+
aria-label={1}
15+
className="link"
16+
dangerouslySetInnerHTML={
17+
Object {
18+
"__html": 1,
19+
}
20+
}
21+
href="[0]"
22+
onClick={[Function]}
23+
/>
24+
</li>
25+
<li
26+
className="item pageItem"
27+
>
28+
<a
29+
aria-label={2}
30+
className="link"
31+
dangerouslySetInnerHTML={
32+
Object {
33+
"__html": 2,
34+
}
35+
}
36+
href="[1]"
37+
onClick={[Function]}
38+
/>
39+
</li>
40+
<li
41+
className="item pageItem"
42+
>
43+
<a
44+
aria-label={3}
45+
className="link"
46+
dangerouslySetInnerHTML={
47+
Object {
48+
"__html": 3,
49+
}
50+
}
51+
href="[2]"
52+
onClick={[Function]}
53+
/>
54+
</li>
55+
<li
56+
className="item pageItem"
57+
>
58+
<a
59+
aria-label={4}
60+
className="link"
61+
dangerouslySetInnerHTML={
62+
Object {
63+
"__html": 4,
64+
}
65+
}
66+
href="[3]"
67+
onClick={[Function]}
68+
/>
69+
</li>
70+
<li
71+
className="item pageItem"
72+
>
73+
<a
74+
aria-label={5}
75+
className="link"
76+
dangerouslySetInnerHTML={
77+
Object {
78+
"__html": 5,
79+
}
80+
}
81+
href="[4]"
82+
onClick={[Function]}
83+
/>
84+
</li>
85+
<li
86+
className="item pageItem"
87+
>
88+
<a
89+
aria-label={6}
90+
className="link"
91+
dangerouslySetInnerHTML={
92+
Object {
93+
"__html": 6,
94+
}
95+
}
96+
href="[5]"
97+
onClick={[Function]}
98+
/>
99+
</li>
100+
<li
101+
className="item pageItem"
102+
>
103+
<a
104+
aria-label={7}
105+
className="link"
106+
dangerouslySetInnerHTML={
107+
Object {
108+
"__html": 7,
109+
}
110+
}
111+
href="[6]"
112+
onClick={[Function]}
113+
/>
114+
</li>
115+
</ul>
116+
</div>
117+
`;
118+
3119
exports[`Pagination should disable last page if already on it 1`] = `
4120
<div
5121
className="root"
@@ -172,7 +288,7 @@ exports[`Pagination should disable last page if already on it 1`] = `
172288

173289
exports[`Pagination should display the first/last link 1`] = `
174290
<div
175-
className="root noRefinementRoot"
291+
className="root"
176292
>
177293
<ul
178294
className="list"
@@ -389,7 +505,7 @@ exports[`Pagination should have all buttons disabled if there are no results 1`]
389505

390506
exports[`Pagination should render five elements 1`] = `
391507
<div
392-
className="root noRefinementRoot"
508+
className="root"
393509
>
394510
<ul
395511
className="list"

0 commit comments

Comments
 (0)