@dhis2-ui/pagination 9.12.0 → 9.14.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.
- package/build/cjs/__tests__/page-controls.test.js +6 -6
- package/build/cjs/__tests__/page-select.test.js +2 -2
- package/build/cjs/__tests__/page-size-select.test.js +2 -2
- package/build/cjs/__tests__/page-summary.test.js +4 -4
- package/build/cjs/__tests__/pagination.test.js +15 -15
- package/build/es/__tests__/page-controls.test.js +6 -6
- package/build/es/__tests__/page-select.test.js +2 -2
- package/build/es/__tests__/page-size-select.test.js +2 -2
- package/build/es/__tests__/page-summary.test.js +4 -4
- package/build/es/__tests__/pagination.test.js +15 -15
- package/package.json +9 -9
|
@@ -18,35 +18,35 @@ describe('<PageControls />', () => {
|
|
|
18
18
|
mockOnClick.mockClear();
|
|
19
19
|
});
|
|
20
20
|
it('renders without errors', () => {
|
|
21
|
-
(0, _enzyme.shallow)(
|
|
21
|
+
(0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageControls.PageControls, props));
|
|
22
22
|
});
|
|
23
23
|
it('enables all buttons on by default', () => {
|
|
24
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
24
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageControls.PageControls, props));
|
|
25
25
|
expect(wrapper.find('.button-previous').getElement().props.disabled).toBeFalsy();
|
|
26
26
|
expect(wrapper.find('.button-next').getElement().props.disabled).toBeFalsy();
|
|
27
27
|
});
|
|
28
28
|
it('disables the previous page button when isPreviousDisabled is true', () => {
|
|
29
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
29
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageControls.PageControls, _extends({}, props, {
|
|
30
30
|
isPreviousDisabled: true
|
|
31
31
|
})));
|
|
32
32
|
expect(wrapper.find('.button-previous').getElement().props.disabled).toBe(true);
|
|
33
33
|
expect(wrapper.find('.button-next').getElement().props.disabled).toBeFalsy();
|
|
34
34
|
});
|
|
35
35
|
it('disables the next page button when isNextDisabled is true', () => {
|
|
36
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
36
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageControls.PageControls, _extends({}, props, {
|
|
37
37
|
isNextDisabled: true
|
|
38
38
|
})));
|
|
39
39
|
expect(wrapper.find('.button-previous').getElement().props.disabled).toBeFalsy();
|
|
40
40
|
expect(wrapper.find('.button-next').getElement().props.disabled).toBe(true);
|
|
41
41
|
});
|
|
42
42
|
it('calls the onClick handler with the value for the next page when next is clicked', () => {
|
|
43
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
43
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageControls.PageControls, props));
|
|
44
44
|
wrapper.find('.button-next').simulate('click');
|
|
45
45
|
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
46
46
|
expect(mockOnClick).toHaveBeenCalledWith(11);
|
|
47
47
|
});
|
|
48
48
|
it('calls the onClick handler with the value for the previous page when previous is clicked', () => {
|
|
49
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
49
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageControls.PageControls, props));
|
|
50
50
|
wrapper.find('.button-previous').simulate('click');
|
|
51
51
|
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
52
52
|
expect(mockOnClick).toHaveBeenCalledWith(9);
|
|
@@ -20,10 +20,10 @@ describe('<PageSelect />', () => {
|
|
|
20
20
|
mockOnSelect.mockClear();
|
|
21
21
|
});
|
|
22
22
|
it('renders without errors', () => {
|
|
23
|
-
(0, _enzyme.shallow)(
|
|
23
|
+
(0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageSelect.PageSelect, props));
|
|
24
24
|
});
|
|
25
25
|
it('calls the onSelect handler with the value of selected option', () => {
|
|
26
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
26
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageSelect.PageSelect, props));
|
|
27
27
|
wrapper.find(_select.SingleSelect).simulate('change', {
|
|
28
28
|
selected: '10'
|
|
29
29
|
});
|
|
@@ -18,10 +18,10 @@ describe('<PageSizeSelect />', () => {
|
|
|
18
18
|
...mockPagers.atTenthPage
|
|
19
19
|
};
|
|
20
20
|
it('renders without errors', () => {
|
|
21
|
-
(0, _enzyme.shallow)(
|
|
21
|
+
(0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageSizeSelect.PageSizeSelect, props));
|
|
22
22
|
});
|
|
23
23
|
it('calls the onSelect handler with the value of selected option', () => {
|
|
24
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
24
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageSizeSelect.PageSizeSelect, props));
|
|
25
25
|
wrapper.find(_select.SingleSelect).simulate('change', {
|
|
26
26
|
selected: '10'
|
|
27
27
|
});
|
|
@@ -12,7 +12,7 @@ describe('<PageSummary />', () => {
|
|
|
12
12
|
pageSummaryText: _getDefaultPageSummaryText.getDefaultPageSummaryText
|
|
13
13
|
};
|
|
14
14
|
it('renders without errors', () => {
|
|
15
|
-
(0, _enzyme.shallow)(
|
|
15
|
+
(0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageSummary.PageSummary, _extends({}, props, {
|
|
16
16
|
firstItem: 51,
|
|
17
17
|
lastItem: 100,
|
|
18
18
|
page: 2,
|
|
@@ -21,7 +21,7 @@ describe('<PageSummary />', () => {
|
|
|
21
21
|
})));
|
|
22
22
|
});
|
|
23
23
|
it('renders the correct message when both total and lastItem are provided', () => {
|
|
24
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
24
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageSummary.PageSummary, _extends({}, props, {
|
|
25
25
|
firstItem: 51,
|
|
26
26
|
lastItem: 100,
|
|
27
27
|
page: 2,
|
|
@@ -32,7 +32,7 @@ describe('<PageSummary />', () => {
|
|
|
32
32
|
expect(wrapper.find('span').text()).toBe(expectedString);
|
|
33
33
|
});
|
|
34
34
|
it('renders the correct message when only lastItem is provided', () => {
|
|
35
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
35
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageSummary.PageSummary, _extends({}, props, {
|
|
36
36
|
firstItem: 51,
|
|
37
37
|
lastItem: 100,
|
|
38
38
|
page: 2,
|
|
@@ -42,7 +42,7 @@ describe('<PageSummary />', () => {
|
|
|
42
42
|
expect(wrapper.find('span').text()).toBe(expectedString);
|
|
43
43
|
});
|
|
44
44
|
it('renders the correct message when total is missing and lastItem is not a number', () => {
|
|
45
|
-
const wrapper = (0, _enzyme.shallow)(
|
|
45
|
+
const wrapper = (0, _enzyme.shallow)(/*#__PURE__*/_react.default.createElement(_pageSummary.PageSummary, _extends({}, props, {
|
|
46
46
|
firstItem: 51,
|
|
47
47
|
lastItem: NaN,
|
|
48
48
|
page: 2,
|
|
@@ -17,12 +17,12 @@ describe('<Pagination />', () => {
|
|
|
17
17
|
onPageSizeChange: () => {}
|
|
18
18
|
};
|
|
19
19
|
it('renders without errors', () => {
|
|
20
|
-
(0, _react.render)(
|
|
20
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, props));
|
|
21
21
|
});
|
|
22
22
|
it('renders a PageSelect and PageSizeSelect by default', () => {
|
|
23
23
|
const {
|
|
24
24
|
getByTestId
|
|
25
|
-
} = (0, _react.render)(
|
|
25
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, props));
|
|
26
26
|
expect(getByTestId('dhis2-uiwidgets-pagination-page-select')).toBeInTheDocument();
|
|
27
27
|
expect(getByTestId('dhis2-uiwidgets-pagination-pagesize')).toBeInTheDocument();
|
|
28
28
|
});
|
|
@@ -30,7 +30,7 @@ describe('<Pagination />', () => {
|
|
|
30
30
|
const {
|
|
31
31
|
getByTestId,
|
|
32
32
|
queryByTestId
|
|
33
|
-
} = (0, _react.render)(
|
|
33
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, props, {
|
|
34
34
|
hidePageSelect: true
|
|
35
35
|
})));
|
|
36
36
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
@@ -40,7 +40,7 @@ describe('<Pagination />', () => {
|
|
|
40
40
|
const {
|
|
41
41
|
getByTestId,
|
|
42
42
|
queryByTestId
|
|
43
|
-
} = (0, _react.render)(
|
|
43
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, props, {
|
|
44
44
|
pageCount: undefined
|
|
45
45
|
})));
|
|
46
46
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
@@ -50,7 +50,7 @@ describe('<Pagination />', () => {
|
|
|
50
50
|
const {
|
|
51
51
|
getByTestId,
|
|
52
52
|
queryByTestId
|
|
53
|
-
} = (0, _react.render)(
|
|
53
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, props, {
|
|
54
54
|
pageCount: 1
|
|
55
55
|
})));
|
|
56
56
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
@@ -60,7 +60,7 @@ describe('<Pagination />', () => {
|
|
|
60
60
|
const {
|
|
61
61
|
getByTestId,
|
|
62
62
|
queryByTestId
|
|
63
|
-
} = (0, _react.render)(
|
|
63
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, props, {
|
|
64
64
|
pageCount: 2001
|
|
65
65
|
})));
|
|
66
66
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
@@ -70,7 +70,7 @@ describe('<Pagination />', () => {
|
|
|
70
70
|
const {
|
|
71
71
|
getByTestId,
|
|
72
72
|
queryByTestId
|
|
73
|
-
} = (0, _react.render)(
|
|
73
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, props, {
|
|
74
74
|
hidePageSizeSelect: true
|
|
75
75
|
})));
|
|
76
76
|
expect(queryByTestId('dhis2-uiwidgets-pagination-pagesize')).not.toBeInTheDocument();
|
|
@@ -79,7 +79,7 @@ describe('<Pagination />', () => {
|
|
|
79
79
|
it('renders without PageSelect and PageSizeSelect when both are true', () => {
|
|
80
80
|
const {
|
|
81
81
|
queryByTestId
|
|
82
|
-
} = (0, _react.render)(
|
|
82
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, props, {
|
|
83
83
|
hidePageSelect: true,
|
|
84
84
|
hidePageSizeSelect: true
|
|
85
85
|
})));
|
|
@@ -90,7 +90,7 @@ describe('<Pagination />', () => {
|
|
|
90
90
|
const {
|
|
91
91
|
getByTestId,
|
|
92
92
|
getByRole
|
|
93
|
-
} = (0, _react.render)(
|
|
93
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, props));
|
|
94
94
|
expect(getByTestId('dhis2-uiwidgets-pagination-pagesize').querySelector('.select .root')).not.toHaveClass('disabled');
|
|
95
95
|
expect(getByTestId('dhis2-uiwidgets-pagination-summary').querySelector('span')).not.toHaveClass('inactive');
|
|
96
96
|
expect(getByTestId('dhis2-uiwidgets-pagination-page-select').querySelector('.select .root')).not.toHaveClass('disabled');
|
|
@@ -105,7 +105,7 @@ describe('<Pagination />', () => {
|
|
|
105
105
|
const {
|
|
106
106
|
getByTestId,
|
|
107
107
|
getByRole
|
|
108
|
-
} = (0, _react.render)(
|
|
108
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, props, {
|
|
109
109
|
disabled: true
|
|
110
110
|
})));
|
|
111
111
|
expect(getByTestId('dhis2-uiwidgets-pagination-pagesize').querySelector('.select .root')).toHaveClass('disabled');
|
|
@@ -121,7 +121,7 @@ describe('<Pagination />', () => {
|
|
|
121
121
|
it('disables previous button when on the first page', () => {
|
|
122
122
|
const {
|
|
123
123
|
getByRole
|
|
124
|
-
} = (0, _react.render)(
|
|
124
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, mockPagers.atFirstPage, {
|
|
125
125
|
onPageChange: () => {},
|
|
126
126
|
onPageSizeChange: () => {}
|
|
127
127
|
})));
|
|
@@ -135,7 +135,7 @@ describe('<Pagination />', () => {
|
|
|
135
135
|
it('disables next button when on the last page', () => {
|
|
136
136
|
const {
|
|
137
137
|
getByRole
|
|
138
|
-
} = (0, _react.render)(
|
|
138
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, mockPagers.atLastPage, {
|
|
139
139
|
onPageChange: () => {},
|
|
140
140
|
onPageSizeChange: () => {}
|
|
141
141
|
})));
|
|
@@ -155,20 +155,20 @@ describe('<Pagination />', () => {
|
|
|
155
155
|
onPageSizeChange: () => {}
|
|
156
156
|
};
|
|
157
157
|
it('renders without errors', () => {
|
|
158
|
-
(0, _react.render)(
|
|
158
|
+
(0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, props));
|
|
159
159
|
});
|
|
160
160
|
it('renders with a PageSizeSelect but without a PageSelect', () => {
|
|
161
161
|
const {
|
|
162
162
|
queryByTestId,
|
|
163
163
|
getByTestId
|
|
164
|
-
} = (0, _react.render)(
|
|
164
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, props));
|
|
165
165
|
expect(getByTestId('dhis2-uiwidgets-pagination-pagesize')).toBeInTheDocument();
|
|
166
166
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
167
167
|
});
|
|
168
168
|
it('prevents forward navigation when on the last page', () => {
|
|
169
169
|
const {
|
|
170
170
|
getByRole
|
|
171
|
-
} = (0, _react.render)(
|
|
171
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_pagination.Pagination, _extends({}, props, mockPagers.noTotalAtLastPage)));
|
|
172
172
|
expect(getByRole('button', {
|
|
173
173
|
name: 'Previous'
|
|
174
174
|
})).not.toBeDisabled();
|
|
@@ -15,35 +15,35 @@ describe('<PageControls />', () => {
|
|
|
15
15
|
mockOnClick.mockClear();
|
|
16
16
|
});
|
|
17
17
|
it('renders without errors', () => {
|
|
18
|
-
shallow(
|
|
18
|
+
shallow(/*#__PURE__*/React.createElement(PageControls, props));
|
|
19
19
|
});
|
|
20
20
|
it('enables all buttons on by default', () => {
|
|
21
|
-
const wrapper = shallow(
|
|
21
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageControls, props));
|
|
22
22
|
expect(wrapper.find('.button-previous').getElement().props.disabled).toBeFalsy();
|
|
23
23
|
expect(wrapper.find('.button-next').getElement().props.disabled).toBeFalsy();
|
|
24
24
|
});
|
|
25
25
|
it('disables the previous page button when isPreviousDisabled is true', () => {
|
|
26
|
-
const wrapper = shallow(
|
|
26
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageControls, _extends({}, props, {
|
|
27
27
|
isPreviousDisabled: true
|
|
28
28
|
})));
|
|
29
29
|
expect(wrapper.find('.button-previous').getElement().props.disabled).toBe(true);
|
|
30
30
|
expect(wrapper.find('.button-next').getElement().props.disabled).toBeFalsy();
|
|
31
31
|
});
|
|
32
32
|
it('disables the next page button when isNextDisabled is true', () => {
|
|
33
|
-
const wrapper = shallow(
|
|
33
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageControls, _extends({}, props, {
|
|
34
34
|
isNextDisabled: true
|
|
35
35
|
})));
|
|
36
36
|
expect(wrapper.find('.button-previous').getElement().props.disabled).toBeFalsy();
|
|
37
37
|
expect(wrapper.find('.button-next').getElement().props.disabled).toBe(true);
|
|
38
38
|
});
|
|
39
39
|
it('calls the onClick handler with the value for the next page when next is clicked', () => {
|
|
40
|
-
const wrapper = shallow(
|
|
40
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageControls, props));
|
|
41
41
|
wrapper.find('.button-next').simulate('click');
|
|
42
42
|
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
43
43
|
expect(mockOnClick).toHaveBeenCalledWith(11);
|
|
44
44
|
});
|
|
45
45
|
it('calls the onClick handler with the value for the previous page when previous is clicked', () => {
|
|
46
|
-
const wrapper = shallow(
|
|
46
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageControls, props));
|
|
47
47
|
wrapper.find('.button-previous').simulate('click');
|
|
48
48
|
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
49
49
|
expect(mockOnClick).toHaveBeenCalledWith(9);
|
|
@@ -15,10 +15,10 @@ describe('<PageSelect />', () => {
|
|
|
15
15
|
mockOnSelect.mockClear();
|
|
16
16
|
});
|
|
17
17
|
it('renders without errors', () => {
|
|
18
|
-
shallow(
|
|
18
|
+
shallow(/*#__PURE__*/React.createElement(PageSelect, props));
|
|
19
19
|
});
|
|
20
20
|
it('calls the onSelect handler with the value of selected option', () => {
|
|
21
|
-
const wrapper = shallow(
|
|
21
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageSelect, props));
|
|
22
22
|
wrapper.find(SingleSelect).simulate('change', {
|
|
23
23
|
selected: '10'
|
|
24
24
|
});
|
|
@@ -13,10 +13,10 @@ describe('<PageSizeSelect />', () => {
|
|
|
13
13
|
...mockPagers.atTenthPage
|
|
14
14
|
};
|
|
15
15
|
it('renders without errors', () => {
|
|
16
|
-
shallow(
|
|
16
|
+
shallow(/*#__PURE__*/React.createElement(PageSizeSelect, props));
|
|
17
17
|
});
|
|
18
18
|
it('calls the onSelect handler with the value of selected option', () => {
|
|
19
|
-
const wrapper = shallow(
|
|
19
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageSizeSelect, props));
|
|
20
20
|
wrapper.find(SingleSelect).simulate('change', {
|
|
21
21
|
selected: '10'
|
|
22
22
|
});
|
|
@@ -9,7 +9,7 @@ describe('<PageSummary />', () => {
|
|
|
9
9
|
pageSummaryText: getDefaultPageSummaryText
|
|
10
10
|
};
|
|
11
11
|
it('renders without errors', () => {
|
|
12
|
-
shallow(
|
|
12
|
+
shallow(/*#__PURE__*/React.createElement(PageSummary, _extends({}, props, {
|
|
13
13
|
firstItem: 51,
|
|
14
14
|
lastItem: 100,
|
|
15
15
|
page: 2,
|
|
@@ -18,7 +18,7 @@ describe('<PageSummary />', () => {
|
|
|
18
18
|
})));
|
|
19
19
|
});
|
|
20
20
|
it('renders the correct message when both total and lastItem are provided', () => {
|
|
21
|
-
const wrapper = shallow(
|
|
21
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageSummary, _extends({}, props, {
|
|
22
22
|
firstItem: 51,
|
|
23
23
|
lastItem: 100,
|
|
24
24
|
page: 2,
|
|
@@ -29,7 +29,7 @@ describe('<PageSummary />', () => {
|
|
|
29
29
|
expect(wrapper.find('span').text()).toBe(expectedString);
|
|
30
30
|
});
|
|
31
31
|
it('renders the correct message when only lastItem is provided', () => {
|
|
32
|
-
const wrapper = shallow(
|
|
32
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageSummary, _extends({}, props, {
|
|
33
33
|
firstItem: 51,
|
|
34
34
|
lastItem: 100,
|
|
35
35
|
page: 2,
|
|
@@ -39,7 +39,7 @@ describe('<PageSummary />', () => {
|
|
|
39
39
|
expect(wrapper.find('span').text()).toBe(expectedString);
|
|
40
40
|
});
|
|
41
41
|
it('renders the correct message when total is missing and lastItem is not a number', () => {
|
|
42
|
-
const wrapper = shallow(
|
|
42
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(PageSummary, _extends({}, props, {
|
|
43
43
|
firstItem: 51,
|
|
44
44
|
lastItem: NaN,
|
|
45
45
|
page: 2,
|
|
@@ -12,12 +12,12 @@ describe('<Pagination />', () => {
|
|
|
12
12
|
onPageSizeChange: () => {}
|
|
13
13
|
};
|
|
14
14
|
it('renders without errors', () => {
|
|
15
|
-
render(
|
|
15
|
+
render(/*#__PURE__*/React.createElement(Pagination, props));
|
|
16
16
|
});
|
|
17
17
|
it('renders a PageSelect and PageSizeSelect by default', () => {
|
|
18
18
|
const {
|
|
19
19
|
getByTestId
|
|
20
|
-
} = render(
|
|
20
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, props));
|
|
21
21
|
expect(getByTestId('dhis2-uiwidgets-pagination-page-select')).toBeInTheDocument();
|
|
22
22
|
expect(getByTestId('dhis2-uiwidgets-pagination-pagesize')).toBeInTheDocument();
|
|
23
23
|
});
|
|
@@ -25,7 +25,7 @@ describe('<Pagination />', () => {
|
|
|
25
25
|
const {
|
|
26
26
|
getByTestId,
|
|
27
27
|
queryByTestId
|
|
28
|
-
} = render(
|
|
28
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, props, {
|
|
29
29
|
hidePageSelect: true
|
|
30
30
|
})));
|
|
31
31
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
@@ -35,7 +35,7 @@ describe('<Pagination />', () => {
|
|
|
35
35
|
const {
|
|
36
36
|
getByTestId,
|
|
37
37
|
queryByTestId
|
|
38
|
-
} = render(
|
|
38
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, props, {
|
|
39
39
|
pageCount: undefined
|
|
40
40
|
})));
|
|
41
41
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
@@ -45,7 +45,7 @@ describe('<Pagination />', () => {
|
|
|
45
45
|
const {
|
|
46
46
|
getByTestId,
|
|
47
47
|
queryByTestId
|
|
48
|
-
} = render(
|
|
48
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, props, {
|
|
49
49
|
pageCount: 1
|
|
50
50
|
})));
|
|
51
51
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
@@ -55,7 +55,7 @@ describe('<Pagination />', () => {
|
|
|
55
55
|
const {
|
|
56
56
|
getByTestId,
|
|
57
57
|
queryByTestId
|
|
58
|
-
} = render(
|
|
58
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, props, {
|
|
59
59
|
pageCount: 2001
|
|
60
60
|
})));
|
|
61
61
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
@@ -65,7 +65,7 @@ describe('<Pagination />', () => {
|
|
|
65
65
|
const {
|
|
66
66
|
getByTestId,
|
|
67
67
|
queryByTestId
|
|
68
|
-
} = render(
|
|
68
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, props, {
|
|
69
69
|
hidePageSizeSelect: true
|
|
70
70
|
})));
|
|
71
71
|
expect(queryByTestId('dhis2-uiwidgets-pagination-pagesize')).not.toBeInTheDocument();
|
|
@@ -74,7 +74,7 @@ describe('<Pagination />', () => {
|
|
|
74
74
|
it('renders without PageSelect and PageSizeSelect when both are true', () => {
|
|
75
75
|
const {
|
|
76
76
|
queryByTestId
|
|
77
|
-
} = render(
|
|
77
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, props, {
|
|
78
78
|
hidePageSelect: true,
|
|
79
79
|
hidePageSizeSelect: true
|
|
80
80
|
})));
|
|
@@ -85,7 +85,7 @@ describe('<Pagination />', () => {
|
|
|
85
85
|
const {
|
|
86
86
|
getByTestId,
|
|
87
87
|
getByRole
|
|
88
|
-
} = render(
|
|
88
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, props));
|
|
89
89
|
expect(getByTestId('dhis2-uiwidgets-pagination-pagesize').querySelector('.select .root')).not.toHaveClass('disabled');
|
|
90
90
|
expect(getByTestId('dhis2-uiwidgets-pagination-summary').querySelector('span')).not.toHaveClass('inactive');
|
|
91
91
|
expect(getByTestId('dhis2-uiwidgets-pagination-page-select').querySelector('.select .root')).not.toHaveClass('disabled');
|
|
@@ -100,7 +100,7 @@ describe('<Pagination />', () => {
|
|
|
100
100
|
const {
|
|
101
101
|
getByTestId,
|
|
102
102
|
getByRole
|
|
103
|
-
} = render(
|
|
103
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, props, {
|
|
104
104
|
disabled: true
|
|
105
105
|
})));
|
|
106
106
|
expect(getByTestId('dhis2-uiwidgets-pagination-pagesize').querySelector('.select .root')).toHaveClass('disabled');
|
|
@@ -116,7 +116,7 @@ describe('<Pagination />', () => {
|
|
|
116
116
|
it('disables previous button when on the first page', () => {
|
|
117
117
|
const {
|
|
118
118
|
getByRole
|
|
119
|
-
} = render(
|
|
119
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, mockPagers.atFirstPage, {
|
|
120
120
|
onPageChange: () => {},
|
|
121
121
|
onPageSizeChange: () => {}
|
|
122
122
|
})));
|
|
@@ -130,7 +130,7 @@ describe('<Pagination />', () => {
|
|
|
130
130
|
it('disables next button when on the last page', () => {
|
|
131
131
|
const {
|
|
132
132
|
getByRole
|
|
133
|
-
} = render(
|
|
133
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, mockPagers.atLastPage, {
|
|
134
134
|
onPageChange: () => {},
|
|
135
135
|
onPageSizeChange: () => {}
|
|
136
136
|
})));
|
|
@@ -150,20 +150,20 @@ describe('<Pagination />', () => {
|
|
|
150
150
|
onPageSizeChange: () => {}
|
|
151
151
|
};
|
|
152
152
|
it('renders without errors', () => {
|
|
153
|
-
render(
|
|
153
|
+
render(/*#__PURE__*/React.createElement(Pagination, props));
|
|
154
154
|
});
|
|
155
155
|
it('renders with a PageSizeSelect but without a PageSelect', () => {
|
|
156
156
|
const {
|
|
157
157
|
queryByTestId,
|
|
158
158
|
getByTestId
|
|
159
|
-
} = render(
|
|
159
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, props));
|
|
160
160
|
expect(getByTestId('dhis2-uiwidgets-pagination-pagesize')).toBeInTheDocument();
|
|
161
161
|
expect(queryByTestId('dhis2-uiwidgets-pagination-page-select')).not.toBeInTheDocument();
|
|
162
162
|
});
|
|
163
163
|
it('prevents forward navigation when on the last page', () => {
|
|
164
164
|
const {
|
|
165
165
|
getByRole
|
|
166
|
-
} = render(
|
|
166
|
+
} = render(/*#__PURE__*/React.createElement(Pagination, _extends({}, props, mockPagers.noTotalAtLastPage)));
|
|
167
167
|
expect(getByRole('button', {
|
|
168
168
|
name: 'Previous'
|
|
169
169
|
})).not.toBeDisabled();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/pagination",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.14.0",
|
|
4
4
|
"description": "UI Pagination",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@dhis2/d2-i18n": "^1",
|
|
31
|
-
"react": "^16.13",
|
|
32
|
-
"react-dom": "^16.13",
|
|
31
|
+
"react": "^16.13 || ^18",
|
|
32
|
+
"react-dom": "^16.13 || ^18",
|
|
33
33
|
"styled-jsx": "^4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@dhis2/prop-types": "^3.1.2",
|
|
37
|
-
"@dhis2-ui/button": "9.
|
|
38
|
-
"@dhis2-ui/select": "9.
|
|
39
|
-
"@dhis2/ui-constants": "9.
|
|
40
|
-
"@dhis2/ui-icons": "9.
|
|
37
|
+
"@dhis2-ui/button": "9.14.0",
|
|
38
|
+
"@dhis2-ui/select": "9.14.0",
|
|
39
|
+
"@dhis2/ui-constants": "9.14.0",
|
|
40
|
+
"@dhis2/ui-icons": "9.14.0",
|
|
41
41
|
"classnames": "^2.3.1",
|
|
42
42
|
"prop-types": "^15.7.2"
|
|
43
43
|
},
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
],
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@dhis2/d2-i18n": "^1.1.0",
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
50
|
+
"react": "^18.3.1",
|
|
51
|
+
"react-dom": "^18.3.1",
|
|
52
52
|
"styled-jsx": "^4.0.1"
|
|
53
53
|
},
|
|
54
54
|
"types": "types"
|