react-router-pagination 3.1.21 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -58
- package/babel.config.cjs +4 -4
- package/package.json +10 -23
- package/src/pagination/centered/index.tsx +33 -5
- package/src/pagination/common/index.cjs +0 -2
- package/src/pagination/component.tsx +18 -18
- package/src/pagination/standard/index.tsx +37 -5
- package/jest.config.cjs +0 -13
- package/src/__tests__/pagination/__snapshots__/component.test.tsx.snap +0 -36
- package/src/__tests__/pagination/__snapshots__/index.test.tsx.snap +0 -190
- package/src/__tests__/pagination/centered/__snapshots__/index.test.tsx.snap +0 -141
- package/src/__tests__/pagination/centered/index.test.tsx +0 -123
- package/src/__tests__/pagination/common/index.test.mts +0 -79
- package/src/__tests__/pagination/component.test.tsx +0 -103
- package/src/__tests__/pagination/index.test.tsx +0 -124
- package/src/__tests__/pagination/standard/__snapshots__/index.test.tsx.snap +0 -141
- package/src/__tests__/pagination/standard/index.test.tsx +0 -123
- package/tsconfig.json +0 -27
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`react-router-pagination <Centered /> With \`pageNumber\` and \`totalPages\` and \`spread\` renders 1`] = `
|
|
4
|
-
<ul
|
|
5
|
-
className="pagination"
|
|
6
|
-
>
|
|
7
|
-
<li
|
|
8
|
-
className="zeroPage"
|
|
9
|
-
>
|
|
10
|
-
<a
|
|
11
|
-
href="/1"
|
|
12
|
-
onClick={[Function]}
|
|
13
|
-
>
|
|
14
|
-
<span
|
|
15
|
-
className="pageNumber"
|
|
16
|
-
>
|
|
17
|
-
1
|
|
18
|
-
</span>
|
|
19
|
-
</a>
|
|
20
|
-
</li>
|
|
21
|
-
<li
|
|
22
|
-
className="reversePage"
|
|
23
|
-
>
|
|
24
|
-
<a
|
|
25
|
-
href="/6"
|
|
26
|
-
onClick={[Function]}
|
|
27
|
-
>
|
|
28
|
-
<span
|
|
29
|
-
className="reverse"
|
|
30
|
-
>
|
|
31
|
-
«
|
|
32
|
-
</span>
|
|
33
|
-
</a>
|
|
34
|
-
</li>
|
|
35
|
-
<li
|
|
36
|
-
className="page"
|
|
37
|
-
>
|
|
38
|
-
<a
|
|
39
|
-
href="/7"
|
|
40
|
-
onClick={[Function]}
|
|
41
|
-
>
|
|
42
|
-
<span
|
|
43
|
-
className="pageNumber"
|
|
44
|
-
>
|
|
45
|
-
7
|
|
46
|
-
</span>
|
|
47
|
-
</a>
|
|
48
|
-
</li>
|
|
49
|
-
<li
|
|
50
|
-
className="page"
|
|
51
|
-
>
|
|
52
|
-
<a
|
|
53
|
-
href="/8"
|
|
54
|
-
onClick={[Function]}
|
|
55
|
-
>
|
|
56
|
-
<span
|
|
57
|
-
className="pageNumber"
|
|
58
|
-
>
|
|
59
|
-
8
|
|
60
|
-
</span>
|
|
61
|
-
</a>
|
|
62
|
-
</li>
|
|
63
|
-
<li
|
|
64
|
-
className="currentPage"
|
|
65
|
-
>
|
|
66
|
-
<a
|
|
67
|
-
href="/9"
|
|
68
|
-
onClick={[Function]}
|
|
69
|
-
>
|
|
70
|
-
<span
|
|
71
|
-
className="pageNumber"
|
|
72
|
-
>
|
|
73
|
-
9
|
|
74
|
-
</span>
|
|
75
|
-
</a>
|
|
76
|
-
</li>
|
|
77
|
-
</ul>
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
exports[`react-router-pagination <Pagination /> With \`pageNumber\` and \`totalPages\` renders 1`] = `
|
|
81
|
-
<ul
|
|
82
|
-
className="pagination"
|
|
83
|
-
>
|
|
84
|
-
<li
|
|
85
|
-
className="forwardPage"
|
|
86
|
-
>
|
|
87
|
-
<a
|
|
88
|
-
href="/1"
|
|
89
|
-
onClick={[Function]}
|
|
90
|
-
>
|
|
91
|
-
<span
|
|
92
|
-
className="forwardPage"
|
|
93
|
-
>
|
|
94
|
-
»
|
|
95
|
-
</span>
|
|
96
|
-
</a>
|
|
97
|
-
</li>
|
|
98
|
-
<li
|
|
99
|
-
className="lastPage"
|
|
100
|
-
>
|
|
101
|
-
<a
|
|
102
|
-
href="/2"
|
|
103
|
-
onClick={[Function]}
|
|
104
|
-
>
|
|
105
|
-
<span
|
|
106
|
-
className="pageNumber"
|
|
107
|
-
>
|
|
108
|
-
2
|
|
109
|
-
</span>
|
|
110
|
-
</a>
|
|
111
|
-
</li>
|
|
112
|
-
</ul>
|
|
113
|
-
`;
|
|
114
|
-
|
|
115
|
-
exports[`react-router-pagination <Standard /> With \`pageNumber\` and \`totalPages\` and \`spread\` renders 1`] = `
|
|
116
|
-
<ul
|
|
117
|
-
className="pagination"
|
|
118
|
-
>
|
|
119
|
-
<li
|
|
120
|
-
className="zeroPage"
|
|
121
|
-
>
|
|
122
|
-
<a
|
|
123
|
-
href="/1"
|
|
124
|
-
onClick={[Function]}
|
|
125
|
-
>
|
|
126
|
-
<span
|
|
127
|
-
className="pageNumber"
|
|
128
|
-
>
|
|
129
|
-
1
|
|
130
|
-
</span>
|
|
131
|
-
</a>
|
|
132
|
-
</li>
|
|
133
|
-
<li
|
|
134
|
-
className="reversePage"
|
|
135
|
-
>
|
|
136
|
-
<a
|
|
137
|
-
href="/6"
|
|
138
|
-
onClick={[Function]}
|
|
139
|
-
>
|
|
140
|
-
<span
|
|
141
|
-
className="reverse"
|
|
142
|
-
>
|
|
143
|
-
«
|
|
144
|
-
</span>
|
|
145
|
-
</a>
|
|
146
|
-
</li>
|
|
147
|
-
<li
|
|
148
|
-
className="page"
|
|
149
|
-
>
|
|
150
|
-
<a
|
|
151
|
-
href="/7"
|
|
152
|
-
onClick={[Function]}
|
|
153
|
-
>
|
|
154
|
-
<span
|
|
155
|
-
className="pageNumber"
|
|
156
|
-
>
|
|
157
|
-
7
|
|
158
|
-
</span>
|
|
159
|
-
</a>
|
|
160
|
-
</li>
|
|
161
|
-
<li
|
|
162
|
-
className="page"
|
|
163
|
-
>
|
|
164
|
-
<a
|
|
165
|
-
href="/8"
|
|
166
|
-
onClick={[Function]}
|
|
167
|
-
>
|
|
168
|
-
<span
|
|
169
|
-
className="pageNumber"
|
|
170
|
-
>
|
|
171
|
-
8
|
|
172
|
-
</span>
|
|
173
|
-
</a>
|
|
174
|
-
</li>
|
|
175
|
-
<li
|
|
176
|
-
className="currentPage"
|
|
177
|
-
>
|
|
178
|
-
<a
|
|
179
|
-
href="/9"
|
|
180
|
-
onClick={[Function]}
|
|
181
|
-
>
|
|
182
|
-
<span
|
|
183
|
-
className="pageNumber"
|
|
184
|
-
>
|
|
185
|
-
9
|
|
186
|
-
</span>
|
|
187
|
-
</a>
|
|
188
|
-
</li>
|
|
189
|
-
</ul>
|
|
190
|
-
`;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`react-router-pagination/pagination/centered <Centered /> With \`pageNumber\` and \`totalPages\` renders 1`] = `
|
|
4
|
-
<ul
|
|
5
|
-
className="pagination"
|
|
6
|
-
>
|
|
7
|
-
<li
|
|
8
|
-
className="currentPage"
|
|
9
|
-
>
|
|
10
|
-
<a
|
|
11
|
-
href="/1"
|
|
12
|
-
onClick={[Function]}
|
|
13
|
-
>
|
|
14
|
-
<span
|
|
15
|
-
className="pageNumber"
|
|
16
|
-
>
|
|
17
|
-
1
|
|
18
|
-
</span>
|
|
19
|
-
</a>
|
|
20
|
-
</li>
|
|
21
|
-
<li
|
|
22
|
-
className="page"
|
|
23
|
-
>
|
|
24
|
-
<a
|
|
25
|
-
href="/2"
|
|
26
|
-
onClick={[Function]}
|
|
27
|
-
>
|
|
28
|
-
<span
|
|
29
|
-
className="pageNumber"
|
|
30
|
-
>
|
|
31
|
-
2
|
|
32
|
-
</span>
|
|
33
|
-
</a>
|
|
34
|
-
</li>
|
|
35
|
-
</ul>
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
exports[`react-router-pagination/pagination/centered <Centered /> With \`spread\` renders 1`] = `
|
|
39
|
-
<ul
|
|
40
|
-
className="pagination"
|
|
41
|
-
>
|
|
42
|
-
<li
|
|
43
|
-
className="zeroPage"
|
|
44
|
-
>
|
|
45
|
-
<a
|
|
46
|
-
href="/1"
|
|
47
|
-
onClick={[Function]}
|
|
48
|
-
>
|
|
49
|
-
<span
|
|
50
|
-
className="pageNumber"
|
|
51
|
-
>
|
|
52
|
-
1
|
|
53
|
-
</span>
|
|
54
|
-
</a>
|
|
55
|
-
</li>
|
|
56
|
-
<li
|
|
57
|
-
className="reversePage"
|
|
58
|
-
>
|
|
59
|
-
<a
|
|
60
|
-
href="/3"
|
|
61
|
-
onClick={[Function]}
|
|
62
|
-
>
|
|
63
|
-
<span
|
|
64
|
-
className="reverse"
|
|
65
|
-
>
|
|
66
|
-
«
|
|
67
|
-
</span>
|
|
68
|
-
</a>
|
|
69
|
-
</li>
|
|
70
|
-
<li
|
|
71
|
-
className="page"
|
|
72
|
-
>
|
|
73
|
-
<a
|
|
74
|
-
href="/4"
|
|
75
|
-
onClick={[Function]}
|
|
76
|
-
>
|
|
77
|
-
<span
|
|
78
|
-
className="pageNumber"
|
|
79
|
-
>
|
|
80
|
-
4
|
|
81
|
-
</span>
|
|
82
|
-
</a>
|
|
83
|
-
</li>
|
|
84
|
-
<li
|
|
85
|
-
className="currentPage"
|
|
86
|
-
>
|
|
87
|
-
<a
|
|
88
|
-
href="/5"
|
|
89
|
-
onClick={[Function]}
|
|
90
|
-
>
|
|
91
|
-
<span
|
|
92
|
-
className="pageNumber"
|
|
93
|
-
>
|
|
94
|
-
5
|
|
95
|
-
</span>
|
|
96
|
-
</a>
|
|
97
|
-
</li>
|
|
98
|
-
<li
|
|
99
|
-
className="page"
|
|
100
|
-
>
|
|
101
|
-
<a
|
|
102
|
-
href="/6"
|
|
103
|
-
onClick={[Function]}
|
|
104
|
-
>
|
|
105
|
-
<span
|
|
106
|
-
className="pageNumber"
|
|
107
|
-
>
|
|
108
|
-
6
|
|
109
|
-
</span>
|
|
110
|
-
</a>
|
|
111
|
-
</li>
|
|
112
|
-
<li
|
|
113
|
-
className="forwardPage"
|
|
114
|
-
>
|
|
115
|
-
<a
|
|
116
|
-
href="/7"
|
|
117
|
-
onClick={[Function]}
|
|
118
|
-
>
|
|
119
|
-
<span
|
|
120
|
-
className="forwardPage"
|
|
121
|
-
>
|
|
122
|
-
»
|
|
123
|
-
</span>
|
|
124
|
-
</a>
|
|
125
|
-
</li>
|
|
126
|
-
<li
|
|
127
|
-
className="lastPage"
|
|
128
|
-
>
|
|
129
|
-
<a
|
|
130
|
-
href="/9"
|
|
131
|
-
onClick={[Function]}
|
|
132
|
-
>
|
|
133
|
-
<span
|
|
134
|
-
className="pageNumber"
|
|
135
|
-
>
|
|
136
|
-
9
|
|
137
|
-
</span>
|
|
138
|
-
</a>
|
|
139
|
-
</li>
|
|
140
|
-
</ul>
|
|
141
|
-
`;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import renderer from 'react-test-renderer'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
MemoryRouter
|
|
6
|
-
} from 'react-router-dom'
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
toInteger,
|
|
10
|
-
calculateTotalPages,
|
|
11
|
-
calculatePageNumber,
|
|
12
|
-
Centered
|
|
13
|
-
} from '#pagination/centered/index.tsx'
|
|
14
|
-
|
|
15
|
-
describe('react-router-pagination/pagination/centered', () => {
|
|
16
|
-
describe('`toInteger`', () => {
|
|
17
|
-
it('is a function', () => {
|
|
18
|
-
expect(toInteger)
|
|
19
|
-
.toEqual(expect.any(Function))
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
describe('`calculateTotalPages`', () => {
|
|
24
|
-
it('is a function', () => {
|
|
25
|
-
expect(calculateTotalPages)
|
|
26
|
-
.toEqual(expect.any(Function))
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
describe('`calculatePageNumber`', () => {
|
|
31
|
-
it('is a function', () => {
|
|
32
|
-
expect(calculatePageNumber)
|
|
33
|
-
.toEqual(expect.any(Function))
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
describe('<Centered />', () => {
|
|
38
|
-
describe('With `pageNumber` and `totalPages`', () => {
|
|
39
|
-
it('renders', () => {
|
|
40
|
-
const rendered = renderer.create(
|
|
41
|
-
<MemoryRouter>
|
|
42
|
-
<Centered
|
|
43
|
-
pageNumber={1}
|
|
44
|
-
totalPages={2}
|
|
45
|
-
/>
|
|
46
|
-
</MemoryRouter>
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
expect(rendered.toJSON())
|
|
50
|
-
.toMatchSnapshot()
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
describe('With `spread`', () => {
|
|
55
|
-
it('renders', () => {
|
|
56
|
-
const rendered = renderer.create(
|
|
57
|
-
<MemoryRouter>
|
|
58
|
-
<Centered
|
|
59
|
-
pageNumber={5}
|
|
60
|
-
totalPages={9}
|
|
61
|
-
spread={3}
|
|
62
|
-
/>
|
|
63
|
-
</MemoryRouter>
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
expect(rendered.toJSON())
|
|
67
|
-
.toMatchSnapshot()
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
describe('`Centered.calculateTotalPages()`', () => {
|
|
73
|
-
describe('Your data contains 120 items which you want to display at 10 items per page', () => {
|
|
74
|
-
it('returns 12', () => {
|
|
75
|
-
expect(Centered.calculateTotalPages(120, 10)).toBe(12)
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
describe('Your data contains 60 items which you want to display at 5 items per page', () => {
|
|
80
|
-
it('returns 12', () => {
|
|
81
|
-
expect(Centered.calculateTotalPages(60, 5)).toBe(12)
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
describe('Your data contains 240 items which you want to display at 20 items per page', () => {
|
|
86
|
-
it('returns 12', () => {
|
|
87
|
-
expect(Centered.calculateTotalPages(240, 20)).toBe(12)
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
describe('Your data contains 121 items which you want to display at 10 items per page', () => {
|
|
92
|
-
it('returns 13', () => {
|
|
93
|
-
expect(Centered.calculateTotalPages(121, 10)).toBe(13)
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
describe('Your data contains 61 items which you want to display at 5 items per page', () => {
|
|
98
|
-
it('returns 13', () => {
|
|
99
|
-
expect(Centered.calculateTotalPages(61, 5)).toBe(13)
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
describe('Your data contains 241 items which you want to display at 20 items per page', () => {
|
|
104
|
-
it('returns 13', () => {
|
|
105
|
-
expect(Centered.calculateTotalPages(241, 20)).toBe(13)
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
describe('`Centered.calculatePageNumber()`', () => {
|
|
111
|
-
describe('Min', () => {
|
|
112
|
-
it('returns 1', () => {
|
|
113
|
-
expect(Centered.calculatePageNumber(0, 12)).toBe(1)
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
describe('Max', () => {
|
|
118
|
-
it('returns 12', () => {
|
|
119
|
-
expect(Centered.calculatePageNumber(13, 12)).toBe(12)
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
})
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
toInteger,
|
|
3
|
-
calculateTotalPages,
|
|
4
|
-
calculatePageNumber
|
|
5
|
-
} from '#pagination/common/index.mts'
|
|
6
|
-
|
|
7
|
-
describe('react-router-pagination/pagination/common', () => {
|
|
8
|
-
describe('`toInteger()`', () => {
|
|
9
|
-
describe('A number', () => {
|
|
10
|
-
it('returns a number', () => {
|
|
11
|
-
expect(toInteger(1)).toBe(1)
|
|
12
|
-
})
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
describe('A string representing a number', () => {
|
|
16
|
-
it('returns a number', () => {
|
|
17
|
-
expect(toInteger('1')).toBe(1)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
describe('A string', () => {
|
|
22
|
-
it('returns a number', () => {
|
|
23
|
-
expect(toInteger('A')).toBe(0)
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
describe('`calculateTotalPages()`', () => {
|
|
29
|
-
describe('Your data contains 120 items which you want to display at 10 items per page', () => {
|
|
30
|
-
it('returns 12', () => {
|
|
31
|
-
expect(calculateTotalPages(120, 10)).toBe(12)
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe('Your data contains 60 items which you want to display at 5 items per page', () => {
|
|
36
|
-
it('returns 12', () => {
|
|
37
|
-
expect(calculateTotalPages(60, 5)).toBe(12)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
describe('Your data contains 240 items which you want to display at 20 items per page', () => {
|
|
42
|
-
it('returns 12', () => {
|
|
43
|
-
expect(calculateTotalPages(240, 20)).toBe(12)
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
describe('Your data contains 121 items which you want to display at 10 items per page', () => {
|
|
48
|
-
it('returns 13', () => {
|
|
49
|
-
expect(calculateTotalPages(121, 10)).toBe(13)
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
describe('Your data contains 61 items which you want to display at 5 items per page', () => {
|
|
54
|
-
it('returns 13', () => {
|
|
55
|
-
expect(calculateTotalPages(61, 5)).toBe(13)
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
describe('Your data contains 241 items which you want to display at 20 items per page', () => {
|
|
60
|
-
it('returns 13', () => {
|
|
61
|
-
expect(calculateTotalPages(241, 20)).toBe(13)
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
describe('`calculatePageNumber()`', () => {
|
|
67
|
-
describe('Min', () => {
|
|
68
|
-
it('returns 1', () => {
|
|
69
|
-
expect(calculatePageNumber(0, 12)).toBe(1)
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
describe('Max', () => {
|
|
74
|
-
it('returns 12', () => {
|
|
75
|
-
expect(calculatePageNumber(13, 12)).toBe(12)
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
})
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import renderer from 'react-test-renderer'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
MemoryRouter
|
|
6
|
-
} from 'react-router-dom'
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
toInteger,
|
|
10
|
-
calculateTotalPages,
|
|
11
|
-
calculatePageNumber,
|
|
12
|
-
Pagination
|
|
13
|
-
} from '#pagination/component.tsx'
|
|
14
|
-
|
|
15
|
-
describe('react-router-pagination/pagination/component', () => {
|
|
16
|
-
describe('`toInteger`', () => {
|
|
17
|
-
it('is a function', () => {
|
|
18
|
-
expect(toInteger)
|
|
19
|
-
.toEqual(expect.any(Function))
|
|
20
|
-
})
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
describe('`calculateTotalPages`', () => {
|
|
24
|
-
it('is a function', () => {
|
|
25
|
-
expect(calculateTotalPages)
|
|
26
|
-
.toEqual(expect.any(Function))
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
describe('`calculatePageNumber`', () => {
|
|
31
|
-
it('is a function', () => {
|
|
32
|
-
expect(calculatePageNumber)
|
|
33
|
-
.toEqual(expect.any(Function))
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
describe('<Pagination />', () => {
|
|
38
|
-
describe('With `pageNumber` and `totalPages`', () => {
|
|
39
|
-
it('renders', () => {
|
|
40
|
-
const rendered = renderer.create(
|
|
41
|
-
<MemoryRouter>
|
|
42
|
-
<Pagination pageNumber={1} totalPages={2} />
|
|
43
|
-
</MemoryRouter>
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
expect(rendered.toJSON())
|
|
47
|
-
.toMatchSnapshot()
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
describe('`Pagination.calculateTotalPages()`', () => {
|
|
53
|
-
describe('Your data contains 120 items which you want to display at 10 items per page', () => {
|
|
54
|
-
it('returns 12', () => {
|
|
55
|
-
expect(Pagination.calculateTotalPages(120, 10)).toBe(12)
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
describe('Your data contains 60 items which you want to display at 5 items per page', () => {
|
|
60
|
-
it('returns 12', () => {
|
|
61
|
-
expect(Pagination.calculateTotalPages(60, 5)).toBe(12)
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
describe('Your data contains 240 items which you want to display at 20 items per page', () => {
|
|
66
|
-
it('returns 12', () => {
|
|
67
|
-
expect(Pagination.calculateTotalPages(240, 20)).toBe(12)
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
describe('Your data contains 121 items which you want to display at 10 items per page', () => {
|
|
72
|
-
it('returns 13', () => {
|
|
73
|
-
expect(Pagination.calculateTotalPages(121, 10)).toBe(13)
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
describe('Your data contains 61 items which you want to display at 5 items per page', () => {
|
|
78
|
-
it('returns 13', () => {
|
|
79
|
-
expect(Pagination.calculateTotalPages(61, 5)).toBe(13)
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
describe('Your data contains 241 items which you want to display at 20 items per page', () => {
|
|
84
|
-
it('returns 13', () => {
|
|
85
|
-
expect(Pagination.calculateTotalPages(241, 20)).toBe(13)
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
describe('`Pagination.calculatePageNumber()`', () => {
|
|
91
|
-
describe('Min', () => {
|
|
92
|
-
it('returns 1', () => {
|
|
93
|
-
expect(Pagination.calculatePageNumber(0, 12)).toBe(1)
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
describe('Max', () => {
|
|
98
|
-
it('returns 12', () => {
|
|
99
|
-
expect(Pagination.calculatePageNumber(13, 12)).toBe(12)
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
})
|
|
103
|
-
})
|