@instructure/ui-pagination 9.2.1-snapshot-1 → 9.2.1-snapshot-3
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/CHANGELOG.md +1 -1
- package/es/Pagination/PaginationArrowButton/__new-tests__/PaginationArrowButton.test.js +2 -1
- package/es/Pagination/PaginationButton/__new-tests__/PaginationButton.test.js +3 -2
- package/es/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.js +8 -7
- package/es/Pagination/__new-tests__/Pagination.test.js +9 -5
- package/lib/Pagination/PaginationArrowButton/__new-tests__/PaginationArrowButton.test.js +2 -1
- package/lib/Pagination/PaginationButton/__new-tests__/PaginationButton.test.js +3 -2
- package/lib/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.js +8 -7
- package/lib/Pagination/__new-tests__/Pagination.test.js +9 -5
- package/package.json +23 -22
- package/src/Pagination/PaginationArrowButton/__new-tests__/PaginationArrowButton.test.tsx +2 -1
- package/src/Pagination/PaginationButton/__new-tests__/PaginationButton.test.tsx +3 -2
- package/src/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.tsx +8 -7
- package/src/Pagination/__new-tests__/Pagination.test.tsx +14 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Pagination/PaginationArrowButton/__new-tests__/PaginationArrowButton.test.d.ts.map +1 -1
- package/types/Pagination/PaginationButton/__new-tests__/PaginationButton.test.d.ts.map +1 -1
- package/types/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.d.ts.map +1 -1
- package/types/Pagination/__new-tests__/Pagination.test.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [9.2.1-snapshot-
|
|
6
|
+
## [9.2.1-snapshot-3](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-3) (2024-07-12)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-pagination
|
|
9
9
|
|
|
@@ -25,6 +25,7 @@ var _PaginationArrowButto;
|
|
|
25
25
|
|
|
26
26
|
import React from 'react';
|
|
27
27
|
import { render, screen } from '@testing-library/react';
|
|
28
|
+
import { vi } from 'vitest';
|
|
28
29
|
import '@testing-library/jest-dom';
|
|
29
30
|
import { PaginationArrowButton } from '../index';
|
|
30
31
|
describe('<PaginationArrowButton />', () => {
|
|
@@ -39,7 +40,7 @@ describe('<PaginationArrowButton />', () => {
|
|
|
39
40
|
expect(button).toBeInTheDocument();
|
|
40
41
|
});
|
|
41
42
|
it('should provide a ref to the button element', async () => {
|
|
42
|
-
const buttonRef =
|
|
43
|
+
const buttonRef = vi.fn();
|
|
43
44
|
render( /*#__PURE__*/React.createElement(PaginationArrowButton, {
|
|
44
45
|
direction: "prev",
|
|
45
46
|
label: "Label",
|
|
@@ -25,6 +25,7 @@ var _PaginationButton, _PaginationButton2;
|
|
|
25
25
|
|
|
26
26
|
import React from 'react';
|
|
27
27
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
28
|
+
import { vi } from 'vitest';
|
|
28
29
|
import '@testing-library/jest-dom';
|
|
29
30
|
import { PaginationButton } from '../index';
|
|
30
31
|
describe('<PaginationButton />', () => {
|
|
@@ -38,7 +39,7 @@ describe('<PaginationButton />', () => {
|
|
|
38
39
|
expect(button).toHaveAttribute('aria-current', 'page');
|
|
39
40
|
});
|
|
40
41
|
it('should navigate using button when onClick provided', async () => {
|
|
41
|
-
const onClick =
|
|
42
|
+
const onClick = vi.fn();
|
|
42
43
|
render( /*#__PURE__*/React.createElement(PaginationButton, {
|
|
43
44
|
onClick: onClick
|
|
44
45
|
}, "1"));
|
|
@@ -51,7 +52,7 @@ describe('<PaginationButton />', () => {
|
|
|
51
52
|
});
|
|
52
53
|
});
|
|
53
54
|
it('should disable navigation to current page', async () => {
|
|
54
|
-
const onClick =
|
|
55
|
+
const onClick = vi.fn();
|
|
55
56
|
render( /*#__PURE__*/React.createElement(PaginationButton, {
|
|
56
57
|
onClick: onClick,
|
|
57
58
|
current: true
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { render, screen } from '@testing-library/react';
|
|
27
|
+
import { vi } from 'vitest';
|
|
27
28
|
import '@testing-library/jest-dom';
|
|
28
29
|
import { PaginationPageInput } from '../index';
|
|
29
30
|
const defaultSRLabel = (currentPage, numberOfPages) => `Select page (${currentPage} of ${numberOfPages})`;
|
|
30
31
|
describe('<PaginationPageInput />', () => {
|
|
31
32
|
it('should render', async () => {
|
|
32
|
-
const defaultOnChange =
|
|
33
|
+
const defaultOnChange = vi.fn();
|
|
33
34
|
render( /*#__PURE__*/React.createElement(PaginationPageInput, {
|
|
34
35
|
numberOfPages: 10,
|
|
35
36
|
currentPageIndex: 0,
|
|
@@ -41,7 +42,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
41
42
|
expect(input.tagName).toBe('INPUT');
|
|
42
43
|
});
|
|
43
44
|
it('should display the current page number', async () => {
|
|
44
|
-
const defaultOnChange =
|
|
45
|
+
const defaultOnChange = vi.fn();
|
|
45
46
|
render( /*#__PURE__*/React.createElement(PaginationPageInput, {
|
|
46
47
|
numberOfPages: 10,
|
|
47
48
|
currentPageIndex: 3,
|
|
@@ -52,7 +53,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
52
53
|
expect(input).toHaveAttribute('value', '4');
|
|
53
54
|
});
|
|
54
55
|
it('should correctly update page number', async () => {
|
|
55
|
-
const defaultOnChange =
|
|
56
|
+
const defaultOnChange = vi.fn();
|
|
56
57
|
const _render = render( /*#__PURE__*/React.createElement(PaginationPageInput, {
|
|
57
58
|
numberOfPages: 10,
|
|
58
59
|
currentPageIndex: 3,
|
|
@@ -73,7 +74,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
73
74
|
expect(input).toHaveAttribute('value', '7');
|
|
74
75
|
});
|
|
75
76
|
it("shouldn't display the arrow keys of NumberInput", async () => {
|
|
76
|
-
const defaultOnChange =
|
|
77
|
+
const defaultOnChange = vi.fn();
|
|
77
78
|
const _render2 = render( /*#__PURE__*/React.createElement(PaginationPageInput, {
|
|
78
79
|
numberOfPages: 10,
|
|
79
80
|
currentPageIndex: 3,
|
|
@@ -87,7 +88,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
87
88
|
expect(arrowKeys.length).toBe(0);
|
|
88
89
|
});
|
|
89
90
|
it("should disable the input on 'disabled'", async () => {
|
|
90
|
-
const defaultOnChange =
|
|
91
|
+
const defaultOnChange = vi.fn();
|
|
91
92
|
render( /*#__PURE__*/React.createElement(PaginationPageInput, {
|
|
92
93
|
numberOfPages: 10,
|
|
93
94
|
currentPageIndex: 3,
|
|
@@ -99,7 +100,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
99
100
|
expect(input).toHaveAttribute('disabled');
|
|
100
101
|
});
|
|
101
102
|
it('should set the ScreenReaderLabel for the input', async () => {
|
|
102
|
-
const defaultOnChange =
|
|
103
|
+
const defaultOnChange = vi.fn();
|
|
103
104
|
const _render3 = render( /*#__PURE__*/React.createElement(PaginationPageInput, {
|
|
104
105
|
numberOfPages: 10,
|
|
105
106
|
currentPageIndex: 3,
|
|
@@ -111,7 +112,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
111
112
|
expect(label).toHaveTextContent('Select page (4 of 10)');
|
|
112
113
|
});
|
|
113
114
|
it('should display the number of pages in the label', async () => {
|
|
114
|
-
const defaultOnChange =
|
|
115
|
+
const defaultOnChange = vi.fn();
|
|
115
116
|
const _render4 = render( /*#__PURE__*/React.createElement(PaginationPageInput, {
|
|
116
117
|
numberOfPages: 10,
|
|
117
118
|
currentPageIndex: 3,
|
|
@@ -25,6 +25,7 @@ var _Pagination, _Pagination2, _Pagination3, _Pagination4, _Pagination5, _Pagina
|
|
|
25
25
|
|
|
26
26
|
import React from 'react';
|
|
27
27
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
28
|
+
import { vi } from 'vitest';
|
|
28
29
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
29
30
|
import userEvent from '@testing-library/user-event';
|
|
30
31
|
import '@testing-library/jest-dom';
|
|
@@ -39,12 +40,15 @@ const buildPages = (count = 4, current = 0) => {
|
|
|
39
40
|
});
|
|
40
41
|
};
|
|
41
42
|
describe('<Pagination />', () => {
|
|
43
|
+
let consoleWarningMock;
|
|
42
44
|
let consoleErrorMock;
|
|
43
45
|
beforeEach(() => {
|
|
44
46
|
// Mocking console to prevent test output pollution and expect for messages
|
|
45
|
-
|
|
47
|
+
consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
48
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
46
49
|
});
|
|
47
50
|
afterEach(() => {
|
|
51
|
+
consoleWarningMock.mockRestore();
|
|
48
52
|
consoleErrorMock.mockRestore();
|
|
49
53
|
});
|
|
50
54
|
it('should render all pages buttons', async () => {
|
|
@@ -718,7 +722,7 @@ describe('<Pagination />', () => {
|
|
|
718
722
|
});
|
|
719
723
|
});
|
|
720
724
|
it(`should pass down the elementRef prop`, async () => {
|
|
721
|
-
const elementRef =
|
|
725
|
+
const elementRef = vi.fn();
|
|
722
726
|
const _render19 = render( /*#__PURE__*/React.createElement(Pagination, {
|
|
723
727
|
elementRef: elementRef,
|
|
724
728
|
variant: "compact",
|
|
@@ -729,7 +733,7 @@ describe('<Pagination />', () => {
|
|
|
729
733
|
expect(elementRef).toHaveBeenCalledWith(container.firstChild);
|
|
730
734
|
});
|
|
731
735
|
it('should navigate to adjacent pages', async () => {
|
|
732
|
-
const onClick =
|
|
736
|
+
const onClick = vi.fn();
|
|
733
737
|
render( /*#__PURE__*/React.createElement(Pagination, {
|
|
734
738
|
variant: "compact",
|
|
735
739
|
labelNext: "Next",
|
|
@@ -810,8 +814,8 @@ describe('<Pagination />', () => {
|
|
|
810
814
|
expect(container).toHaveTextContent('number: 6, current: 3');
|
|
811
815
|
});
|
|
812
816
|
it('should change pages on input change', async () => {
|
|
813
|
-
const onClick1 =
|
|
814
|
-
const onClick2 =
|
|
817
|
+
const onClick1 = vi.fn();
|
|
818
|
+
const onClick2 = vi.fn();
|
|
815
819
|
const _render23 = render( /*#__PURE__*/React.createElement(Pagination, {
|
|
816
820
|
variant: "input",
|
|
817
821
|
labelNext: "Next",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
require("@testing-library/jest-dom");
|
|
7
8
|
var _index = require("../index");
|
|
8
9
|
var _PaginationArrowButto;
|
|
@@ -41,7 +42,7 @@ describe('<PaginationArrowButton />', () => {
|
|
|
41
42
|
expect(button).toBeInTheDocument();
|
|
42
43
|
});
|
|
43
44
|
it('should provide a ref to the button element', async () => {
|
|
44
|
-
const buttonRef =
|
|
45
|
+
const buttonRef = _vitest.vi.fn();
|
|
45
46
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationArrowButton, {
|
|
46
47
|
direction: "prev",
|
|
47
48
|
label: "Label",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
require("@testing-library/jest-dom");
|
|
7
8
|
var _index = require("../index");
|
|
8
9
|
var _PaginationButton, _PaginationButton2;
|
|
@@ -40,7 +41,7 @@ describe('<PaginationButton />', () => {
|
|
|
40
41
|
expect(button).toHaveAttribute('aria-current', 'page');
|
|
41
42
|
});
|
|
42
43
|
it('should navigate using button when onClick provided', async () => {
|
|
43
|
-
const onClick =
|
|
44
|
+
const onClick = _vitest.vi.fn();
|
|
44
45
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationButton, {
|
|
45
46
|
onClick: onClick
|
|
46
47
|
}, "1"));
|
|
@@ -53,7 +54,7 @@ describe('<PaginationButton />', () => {
|
|
|
53
54
|
});
|
|
54
55
|
});
|
|
55
56
|
it('should disable navigation to current page', async () => {
|
|
56
|
-
const onClick =
|
|
57
|
+
const onClick = _vitest.vi.fn();
|
|
57
58
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationButton, {
|
|
58
59
|
onClick: onClick,
|
|
59
60
|
current: true
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
require("@testing-library/jest-dom");
|
|
7
8
|
var _index = require("../index");
|
|
8
9
|
/*
|
|
@@ -32,7 +33,7 @@ var _index = require("../index");
|
|
|
32
33
|
const defaultSRLabel = (currentPage, numberOfPages) => `Select page (${currentPage} of ${numberOfPages})`;
|
|
33
34
|
describe('<PaginationPageInput />', () => {
|
|
34
35
|
it('should render', async () => {
|
|
35
|
-
const defaultOnChange =
|
|
36
|
+
const defaultOnChange = _vitest.vi.fn();
|
|
36
37
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
|
|
37
38
|
numberOfPages: 10,
|
|
38
39
|
currentPageIndex: 0,
|
|
@@ -44,7 +45,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
44
45
|
expect(input.tagName).toBe('INPUT');
|
|
45
46
|
});
|
|
46
47
|
it('should display the current page number', async () => {
|
|
47
|
-
const defaultOnChange =
|
|
48
|
+
const defaultOnChange = _vitest.vi.fn();
|
|
48
49
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
|
|
49
50
|
numberOfPages: 10,
|
|
50
51
|
currentPageIndex: 3,
|
|
@@ -55,7 +56,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
55
56
|
expect(input).toHaveAttribute('value', '4');
|
|
56
57
|
});
|
|
57
58
|
it('should correctly update page number', async () => {
|
|
58
|
-
const defaultOnChange =
|
|
59
|
+
const defaultOnChange = _vitest.vi.fn();
|
|
59
60
|
const _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
|
|
60
61
|
numberOfPages: 10,
|
|
61
62
|
currentPageIndex: 3,
|
|
@@ -76,7 +77,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
76
77
|
expect(input).toHaveAttribute('value', '7');
|
|
77
78
|
});
|
|
78
79
|
it("shouldn't display the arrow keys of NumberInput", async () => {
|
|
79
|
-
const defaultOnChange =
|
|
80
|
+
const defaultOnChange = _vitest.vi.fn();
|
|
80
81
|
const _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
|
|
81
82
|
numberOfPages: 10,
|
|
82
83
|
currentPageIndex: 3,
|
|
@@ -90,7 +91,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
90
91
|
expect(arrowKeys.length).toBe(0);
|
|
91
92
|
});
|
|
92
93
|
it("should disable the input on 'disabled'", async () => {
|
|
93
|
-
const defaultOnChange =
|
|
94
|
+
const defaultOnChange = _vitest.vi.fn();
|
|
94
95
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
|
|
95
96
|
numberOfPages: 10,
|
|
96
97
|
currentPageIndex: 3,
|
|
@@ -102,7 +103,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
102
103
|
expect(input).toHaveAttribute('disabled');
|
|
103
104
|
});
|
|
104
105
|
it('should set the ScreenReaderLabel for the input', async () => {
|
|
105
|
-
const defaultOnChange =
|
|
106
|
+
const defaultOnChange = _vitest.vi.fn();
|
|
106
107
|
const _render3 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
|
|
107
108
|
numberOfPages: 10,
|
|
108
109
|
currentPageIndex: 3,
|
|
@@ -114,7 +115,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
114
115
|
expect(label).toHaveTextContent('Select page (4 of 10)');
|
|
115
116
|
});
|
|
116
117
|
it('should display the number of pages in the label', async () => {
|
|
117
|
-
const defaultOnChange =
|
|
118
|
+
const defaultOnChange = _vitest.vi.fn();
|
|
118
119
|
const _render4 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
|
|
119
120
|
numberOfPages: 10,
|
|
120
121
|
currentPageIndex: 3,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
7
8
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
9
|
require("@testing-library/jest-dom");
|
|
@@ -41,12 +42,15 @@ const buildPages = (count = 4, current = 0) => {
|
|
|
41
42
|
});
|
|
42
43
|
};
|
|
43
44
|
describe('<Pagination />', () => {
|
|
45
|
+
let consoleWarningMock;
|
|
44
46
|
let consoleErrorMock;
|
|
45
47
|
beforeEach(() => {
|
|
46
48
|
// Mocking console to prevent test output pollution and expect for messages
|
|
47
|
-
|
|
49
|
+
consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
50
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
48
51
|
});
|
|
49
52
|
afterEach(() => {
|
|
53
|
+
consoleWarningMock.mockRestore();
|
|
50
54
|
consoleErrorMock.mockRestore();
|
|
51
55
|
});
|
|
52
56
|
it('should render all pages buttons', async () => {
|
|
@@ -720,7 +724,7 @@ describe('<Pagination />', () => {
|
|
|
720
724
|
});
|
|
721
725
|
});
|
|
722
726
|
it(`should pass down the elementRef prop`, async () => {
|
|
723
|
-
const elementRef =
|
|
727
|
+
const elementRef = _vitest.vi.fn();
|
|
724
728
|
const _render19 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
|
725
729
|
elementRef: elementRef,
|
|
726
730
|
variant: "compact",
|
|
@@ -731,7 +735,7 @@ describe('<Pagination />', () => {
|
|
|
731
735
|
expect(elementRef).toHaveBeenCalledWith(container.firstChild);
|
|
732
736
|
});
|
|
733
737
|
it('should navigate to adjacent pages', async () => {
|
|
734
|
-
const onClick =
|
|
738
|
+
const onClick = _vitest.vi.fn();
|
|
735
739
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
|
736
740
|
variant: "compact",
|
|
737
741
|
labelNext: "Next",
|
|
@@ -812,8 +816,8 @@ describe('<Pagination />', () => {
|
|
|
812
816
|
expect(container).toHaveTextContent('number: 6, current: 3');
|
|
813
817
|
});
|
|
814
818
|
it('should change pages on input change', async () => {
|
|
815
|
-
const onClick1 =
|
|
816
|
-
const onClick2 =
|
|
819
|
+
const onClick1 = _vitest.vi.fn();
|
|
820
|
+
const onClick2 = _vitest.vi.fn();
|
|
817
821
|
const _render23 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
|
818
822
|
variant: "input",
|
|
819
823
|
labelNext: "Next",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-pagination",
|
|
3
|
-
"version": "9.2.1-snapshot-
|
|
3
|
+
"version": "9.2.1-snapshot-3",
|
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,32 +23,33 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "9.2.1-snapshot-
|
|
27
|
-
"@instructure/ui-babel-preset": "9.2.1-snapshot-
|
|
28
|
-
"@instructure/ui-test-utils": "9.2.1-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "9.2.1-snapshot-3",
|
|
27
|
+
"@instructure/ui-babel-preset": "9.2.1-snapshot-3",
|
|
28
|
+
"@instructure/ui-test-utils": "9.2.1-snapshot-3",
|
|
29
29
|
"@testing-library/jest-dom": "^6.4.5",
|
|
30
30
|
"@testing-library/react": "^15.0.7",
|
|
31
|
-
"@testing-library/user-event": "^14.5.2"
|
|
31
|
+
"@testing-library/user-event": "^14.5.2",
|
|
32
|
+
"vitest": "^1.6.0"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@babel/runtime": "^7.24.5",
|
|
35
|
-
"@instructure/emotion": "9.2.1-snapshot-
|
|
36
|
-
"@instructure/shared-types": "9.2.1-snapshot-
|
|
37
|
-
"@instructure/ui-a11y-content": "9.2.1-snapshot-
|
|
38
|
-
"@instructure/ui-a11y-utils": "9.2.1-snapshot-
|
|
39
|
-
"@instructure/ui-buttons": "9.2.1-snapshot-
|
|
40
|
-
"@instructure/ui-dom-utils": "9.2.1-snapshot-
|
|
41
|
-
"@instructure/ui-icons": "9.2.1-snapshot-
|
|
42
|
-
"@instructure/ui-number-input": "9.2.1-snapshot-
|
|
43
|
-
"@instructure/ui-portal": "9.2.1-snapshot-
|
|
44
|
-
"@instructure/ui-prop-types": "9.2.1-snapshot-
|
|
45
|
-
"@instructure/ui-react-utils": "9.2.1-snapshot-
|
|
46
|
-
"@instructure/ui-testable": "9.2.1-snapshot-
|
|
47
|
-
"@instructure/ui-themes": "9.2.1-snapshot-
|
|
48
|
-
"@instructure/ui-tooltip": "9.2.1-snapshot-
|
|
49
|
-
"@instructure/ui-utils": "9.2.1-snapshot-
|
|
50
|
-
"@instructure/ui-view": "9.2.1-snapshot-
|
|
51
|
-
"@instructure/uid": "9.2.1-snapshot-
|
|
36
|
+
"@instructure/emotion": "9.2.1-snapshot-3",
|
|
37
|
+
"@instructure/shared-types": "9.2.1-snapshot-3",
|
|
38
|
+
"@instructure/ui-a11y-content": "9.2.1-snapshot-3",
|
|
39
|
+
"@instructure/ui-a11y-utils": "9.2.1-snapshot-3",
|
|
40
|
+
"@instructure/ui-buttons": "9.2.1-snapshot-3",
|
|
41
|
+
"@instructure/ui-dom-utils": "9.2.1-snapshot-3",
|
|
42
|
+
"@instructure/ui-icons": "9.2.1-snapshot-3",
|
|
43
|
+
"@instructure/ui-number-input": "9.2.1-snapshot-3",
|
|
44
|
+
"@instructure/ui-portal": "9.2.1-snapshot-3",
|
|
45
|
+
"@instructure/ui-prop-types": "9.2.1-snapshot-3",
|
|
46
|
+
"@instructure/ui-react-utils": "9.2.1-snapshot-3",
|
|
47
|
+
"@instructure/ui-testable": "9.2.1-snapshot-3",
|
|
48
|
+
"@instructure/ui-themes": "9.2.1-snapshot-3",
|
|
49
|
+
"@instructure/ui-tooltip": "9.2.1-snapshot-3",
|
|
50
|
+
"@instructure/ui-utils": "9.2.1-snapshot-3",
|
|
51
|
+
"@instructure/ui-view": "9.2.1-snapshot-3",
|
|
52
|
+
"@instructure/uid": "9.2.1-snapshot-3",
|
|
52
53
|
"prop-types": "^15.8.1"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
26
|
import { render, screen } from '@testing-library/react'
|
|
27
|
+
import { vi } from 'vitest'
|
|
27
28
|
|
|
28
29
|
import '@testing-library/jest-dom'
|
|
29
30
|
import { PaginationArrowButton } from '../index'
|
|
@@ -38,7 +39,7 @@ describe('<PaginationArrowButton />', () => {
|
|
|
38
39
|
})
|
|
39
40
|
|
|
40
41
|
it('should provide a ref to the button element', async () => {
|
|
41
|
-
const buttonRef =
|
|
42
|
+
const buttonRef = vi.fn()
|
|
42
43
|
|
|
43
44
|
render(
|
|
44
45
|
<PaginationArrowButton
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
26
|
import { render, screen, waitFor } from '@testing-library/react'
|
|
27
|
+
import { vi } from 'vitest'
|
|
27
28
|
|
|
28
29
|
import '@testing-library/jest-dom'
|
|
29
30
|
import { PaginationButton } from '../index'
|
|
@@ -37,7 +38,7 @@ describe('<PaginationButton />', () => {
|
|
|
37
38
|
})
|
|
38
39
|
|
|
39
40
|
it('should navigate using button when onClick provided', async () => {
|
|
40
|
-
const onClick =
|
|
41
|
+
const onClick = vi.fn()
|
|
41
42
|
render(<PaginationButton onClick={onClick}>1</PaginationButton>)
|
|
42
43
|
|
|
43
44
|
const button = screen.getByRole('button', { name: '1' })
|
|
@@ -50,7 +51,7 @@ describe('<PaginationButton />', () => {
|
|
|
50
51
|
})
|
|
51
52
|
|
|
52
53
|
it('should disable navigation to current page', async () => {
|
|
53
|
-
const onClick =
|
|
54
|
+
const onClick = vi.fn()
|
|
54
55
|
render(
|
|
55
56
|
<PaginationButton onClick={onClick} current>
|
|
56
57
|
1
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
26
|
import { render, screen } from '@testing-library/react'
|
|
27
|
+
import { vi } from 'vitest'
|
|
27
28
|
|
|
28
29
|
import '@testing-library/jest-dom'
|
|
29
30
|
import { PaginationPageInput } from '../index'
|
|
@@ -33,7 +34,7 @@ const defaultSRLabel = (currentPage: number, numberOfPages: number) =>
|
|
|
33
34
|
|
|
34
35
|
describe('<PaginationPageInput />', () => {
|
|
35
36
|
it('should render', async () => {
|
|
36
|
-
const defaultOnChange =
|
|
37
|
+
const defaultOnChange = vi.fn()
|
|
37
38
|
render(
|
|
38
39
|
<PaginationPageInput
|
|
39
40
|
numberOfPages={10}
|
|
@@ -49,7 +50,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
49
50
|
})
|
|
50
51
|
|
|
51
52
|
it('should display the current page number', async () => {
|
|
52
|
-
const defaultOnChange =
|
|
53
|
+
const defaultOnChange = vi.fn()
|
|
53
54
|
render(
|
|
54
55
|
<PaginationPageInput
|
|
55
56
|
numberOfPages={10}
|
|
@@ -64,7 +65,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
64
65
|
})
|
|
65
66
|
|
|
66
67
|
it('should correctly update page number', async () => {
|
|
67
|
-
const defaultOnChange =
|
|
68
|
+
const defaultOnChange = vi.fn()
|
|
68
69
|
const { rerender } = render(
|
|
69
70
|
<PaginationPageInput
|
|
70
71
|
numberOfPages={10}
|
|
@@ -90,7 +91,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
90
91
|
})
|
|
91
92
|
|
|
92
93
|
it("shouldn't display the arrow keys of NumberInput", async () => {
|
|
93
|
-
const defaultOnChange =
|
|
94
|
+
const defaultOnChange = vi.fn()
|
|
94
95
|
const { container } = render(
|
|
95
96
|
<PaginationPageInput
|
|
96
97
|
numberOfPages={10}
|
|
@@ -107,7 +108,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
107
108
|
})
|
|
108
109
|
|
|
109
110
|
it("should disable the input on 'disabled'", async () => {
|
|
110
|
-
const defaultOnChange =
|
|
111
|
+
const defaultOnChange = vi.fn()
|
|
111
112
|
render(
|
|
112
113
|
<PaginationPageInput
|
|
113
114
|
numberOfPages={10}
|
|
@@ -123,7 +124,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
123
124
|
})
|
|
124
125
|
|
|
125
126
|
it('should set the ScreenReaderLabel for the input', async () => {
|
|
126
|
-
const defaultOnChange =
|
|
127
|
+
const defaultOnChange = vi.fn()
|
|
127
128
|
const { container } = render(
|
|
128
129
|
<PaginationPageInput
|
|
129
130
|
numberOfPages={10}
|
|
@@ -138,7 +139,7 @@ describe('<PaginationPageInput />', () => {
|
|
|
138
139
|
})
|
|
139
140
|
|
|
140
141
|
it('should display the number of pages in the label', async () => {
|
|
141
|
-
const defaultOnChange =
|
|
142
|
+
const defaultOnChange = vi.fn()
|
|
142
143
|
const { container } = render(
|
|
143
144
|
<PaginationPageInput
|
|
144
145
|
numberOfPages={10}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
26
|
import { render, screen, waitFor } from '@testing-library/react'
|
|
27
|
+
import { vi } from 'vitest'
|
|
27
28
|
import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
28
29
|
import userEvent from '@testing-library/user-event'
|
|
29
30
|
|
|
@@ -43,14 +44,21 @@ const buildPages = (count = 4, current = 0) => {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
describe('<Pagination />', () => {
|
|
46
|
-
let
|
|
47
|
+
let consoleWarningMock: ReturnType<typeof vi.spyOn>
|
|
48
|
+
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
47
49
|
|
|
48
50
|
beforeEach(() => {
|
|
49
51
|
// Mocking console to prevent test output pollution and expect for messages
|
|
50
|
-
|
|
52
|
+
consoleWarningMock = vi
|
|
53
|
+
.spyOn(console, 'warn')
|
|
54
|
+
.mockImplementation(() => {}) as any
|
|
55
|
+
consoleErrorMock = vi
|
|
56
|
+
.spyOn(console, 'error')
|
|
57
|
+
.mockImplementation(() => {}) as any
|
|
51
58
|
})
|
|
52
59
|
|
|
53
60
|
afterEach(() => {
|
|
61
|
+
consoleWarningMock.mockRestore()
|
|
54
62
|
consoleErrorMock.mockRestore()
|
|
55
63
|
})
|
|
56
64
|
|
|
@@ -795,7 +803,7 @@ describe('<Pagination />', () => {
|
|
|
795
803
|
})
|
|
796
804
|
|
|
797
805
|
it(`should pass down the elementRef prop`, async () => {
|
|
798
|
-
const elementRef =
|
|
806
|
+
const elementRef = vi.fn()
|
|
799
807
|
|
|
800
808
|
const { container } = render(
|
|
801
809
|
<Pagination
|
|
@@ -811,7 +819,7 @@ describe('<Pagination />', () => {
|
|
|
811
819
|
})
|
|
812
820
|
|
|
813
821
|
it('should navigate to adjacent pages', async () => {
|
|
814
|
-
const onClick =
|
|
822
|
+
const onClick = vi.fn()
|
|
815
823
|
|
|
816
824
|
render(
|
|
817
825
|
<Pagination variant="compact" labelNext="Next" labelPrev="Previous">
|
|
@@ -914,8 +922,8 @@ describe('<Pagination />', () => {
|
|
|
914
922
|
})
|
|
915
923
|
|
|
916
924
|
it('should change pages on input change', async () => {
|
|
917
|
-
const onClick1 =
|
|
918
|
-
const onClick2 =
|
|
925
|
+
const onClick1 = vi.fn()
|
|
926
|
+
const onClick2 = vi.fn()
|
|
919
927
|
|
|
920
928
|
const { container } = render(
|
|
921
929
|
<Pagination
|