react-router-pagination 3.1.21 → 3.2.0

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.
@@ -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
- })
@@ -1,124 +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
- calculateTotalPages,
10
- calculatePageNumber,
11
- Pagination,
12
- Centered,
13
- Standard
14
- } from '#pagination/index.tsx'
15
-
16
- describe('react-router-pagination', () => {
17
- describe('calculateTotalPages()', () => {
18
- describe('Your data contains 120 items which you want to display at 10 items per page', () => {
19
- it('returns 12', () => {
20
- expect(calculateTotalPages(120, 10)).toBe(12)
21
- })
22
- })
23
-
24
- describe('Your data contains 60 items which you want to display at 5 items per page', () => {
25
- it('returns 12', () => {
26
- expect(calculateTotalPages(60, 5)).toBe(12)
27
- })
28
- })
29
-
30
- describe('Your data contains 240 items which you want to display at 20 items per page', () => {
31
- it('returns 12', () => {
32
- expect(calculateTotalPages(240, 20)).toBe(12)
33
- })
34
- })
35
-
36
- describe('Your data contains 121 items which you want to display at 10 items per page', () => {
37
- it('returns 13', () => {
38
- expect(calculateTotalPages(121, 10)).toBe(13)
39
- })
40
- })
41
-
42
- describe('Your data contains 61 items which you want to display at 5 items per page', () => {
43
- it('returns 13', () => {
44
- expect(calculateTotalPages(61, 5)).toBe(13)
45
- })
46
- })
47
-
48
- describe('Your data contains 241 items which you want to display at 20 items per page', () => {
49
- it('returns 13', () => {
50
- expect(calculateTotalPages(241, 20)).toBe(13)
51
- })
52
- })
53
- })
54
-
55
- describe('calculatePageNumber()', () => {
56
- describe('Min', () => {
57
- it('returns 1', () => {
58
- expect(calculatePageNumber(0, 12)).toBe(1)
59
- })
60
- })
61
-
62
- describe('Max', () => {
63
- it('returns 12', () => {
64
- expect(calculatePageNumber(13, 12)).toBe(12)
65
- })
66
- })
67
- })
68
-
69
- describe('<Pagination />', () => {
70
- describe('With `pageNumber` and `totalPages`', () => {
71
- it('renders', () => {
72
- const rendered = renderer.create(
73
- <MemoryRouter>
74
- <Pagination
75
- pageNumber={1}
76
- totalPages={2}
77
- />
78
- </MemoryRouter>
79
- )
80
-
81
- expect(rendered.toJSON())
82
- .toMatchSnapshot()
83
- })
84
- })
85
- })
86
-
87
- describe('<Centered />', () => {
88
- describe('With `pageNumber` and `totalPages` and `spread`', () => {
89
- it('renders', () => {
90
- const rendered = renderer.create(
91
- <MemoryRouter>
92
- <Centered
93
- pageNumber={9}
94
- totalPages={9}
95
- spread={3}
96
- />
97
- </MemoryRouter>
98
- )
99
-
100
- expect(rendered.toJSON())
101
- .toMatchSnapshot()
102
- })
103
- })
104
- })
105
-
106
- describe('<Standard />', () => {
107
- describe('With `pageNumber` and `totalPages` and `spread`', () => {
108
- it('renders', () => {
109
- const rendered = renderer.create(
110
- <MemoryRouter>
111
- <Standard
112
- pageNumber={9}
113
- totalPages={9}
114
- spread={3}
115
- />
116
- </MemoryRouter>
117
- )
118
-
119
- expect(rendered.toJSON())
120
- .toMatchSnapshot()
121
- })
122
- })
123
- })
124
- })
@@ -1,141 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`react-router-pagination/pagination/standard <Standard /> With \`pageNumber\` and \`totalPages\` With \`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="/3"
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="/4"
40
- onClick={[Function]}
41
- >
42
- <span
43
- className="pageNumber"
44
- >
45
- 4
46
- </span>
47
- </a>
48
- </li>
49
- <li
50
- className="currentPage"
51
- >
52
- <a
53
- href="/5"
54
- onClick={[Function]}
55
- >
56
- <span
57
- className="pageNumber"
58
- >
59
- 5
60
- </span>
61
- </a>
62
- </li>
63
- <li
64
- className="page"
65
- >
66
- <a
67
- href="/6"
68
- onClick={[Function]}
69
- >
70
- <span
71
- className="pageNumber"
72
- >
73
- 6
74
- </span>
75
- </a>
76
- </li>
77
- <li
78
- className="forwardPage"
79
- >
80
- <a
81
- href="/7"
82
- onClick={[Function]}
83
- >
84
- <span
85
- className="forwardPage"
86
- >
87
- »
88
- </span>
89
- </a>
90
- </li>
91
- <li
92
- className="lastPage"
93
- >
94
- <a
95
- href="/9"
96
- onClick={[Function]}
97
- >
98
- <span
99
- className="pageNumber"
100
- >
101
- 9
102
- </span>
103
- </a>
104
- </li>
105
- </ul>
106
- `;
107
-
108
- exports[`react-router-pagination/pagination/standard <Standard /> With \`pageNumber\` and \`totalPages\` renders 1`] = `
109
- <ul
110
- className="pagination"
111
- >
112
- <li
113
- className="currentPage"
114
- >
115
- <a
116
- href="/1"
117
- onClick={[Function]}
118
- >
119
- <span
120
- className="pageNumber"
121
- >
122
- 1
123
- </span>
124
- </a>
125
- </li>
126
- <li
127
- className="lastPage"
128
- >
129
- <a
130
- href="/2"
131
- onClick={[Function]}
132
- >
133
- <span
134
- className="pageNumber"
135
- >
136
- 2
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
- Standard
13
- } from '#pagination/standard/index.tsx'
14
-
15
- describe('react-router-pagination/pagination/standard', () => {
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('<Standard />', () => {
38
- describe('With `pageNumber` and `totalPages`', () => {
39
- it('renders', () => {
40
- const rendered = renderer.create(
41
- <MemoryRouter>
42
- <Standard
43
- pageNumber={1}
44
- totalPages={2}
45
- />
46
- </MemoryRouter>
47
- )
48
-
49
- expect(rendered.toJSON())
50
- .toMatchSnapshot()
51
- })
52
-
53
- describe('With `spread`', () => {
54
- it('renders', () => {
55
- const rendered = renderer.create(
56
- <MemoryRouter>
57
- <Standard
58
- pageNumber={5}
59
- totalPages={9}
60
- spread={3}
61
- />
62
- </MemoryRouter>
63
- )
64
-
65
- expect(rendered.toJSON())
66
- .toMatchSnapshot()
67
- })
68
- })
69
- })
70
- })
71
-
72
- describe('`Standard.calculateTotalPages()`', () => {
73
- describe('Your data contains 120 items which you want to display at 10 items per page', () => {
74
- it('returns 12', () => {
75
- expect(Standard.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(Standard.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(Standard.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(Standard.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(Standard.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(Standard.calculateTotalPages(241, 20)).toBe(13)
106
- })
107
- })
108
- })
109
-
110
- describe('`Standard.calculatePageNumber()`', () => {
111
- describe('Min', () => {
112
- it('returns 1', () => {
113
- expect(Standard.calculatePageNumber(0, 12)).toBe(1)
114
- })
115
- })
116
-
117
- describe('Max', () => {
118
- it('returns 12', () => {
119
- expect(Standard.calculatePageNumber(13, 12)).toBe(12)
120
- })
121
- })
122
- })
123
- })