@instructure/ui-pagination 9.0.2-snapshot-9 → 9.0.2-snapshot-10

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/{lib/Pagination/PaginationPageInput/PaginationPageInputLocator.js → es/Pagination/PaginationArrowButton/__new-tests__/PaginationArrowButton.test.js} +28 -17
  3. package/es/Pagination/PaginationButton/__new-tests__/PaginationButton.test.js +74 -0
  4. package/es/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.js +126 -0
  5. package/es/Pagination/__new-tests__/Pagination.test.js +834 -27
  6. package/lib/Pagination/PaginationArrowButton/{PaginationArrowButtonLocator.js → __new-tests__/PaginationArrowButton.test.js} +29 -19
  7. package/lib/Pagination/PaginationButton/__new-tests__/PaginationButton.test.js +76 -0
  8. package/lib/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.js +129 -0
  9. package/lib/Pagination/__new-tests__/Pagination.test.js +832 -25
  10. package/package.json +23 -23
  11. package/src/Pagination/{PaginationPageInput/PaginationPageInputLocator.ts → PaginationArrowButton/__new-tests__/PaginationArrowButton.test.tsx} +25 -13
  12. package/src/Pagination/PaginationButton/__new-tests__/PaginationButton.test.tsx +76 -0
  13. package/src/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.tsx +155 -0
  14. package/src/Pagination/__new-tests__/Pagination.test.tsx +918 -2
  15. package/tsconfig.build.json +1 -2
  16. package/tsconfig.build.tsbuildinfo +1 -1
  17. package/types/Pagination/PaginationArrowButton/__new-tests__/PaginationArrowButton.test.d.ts +2 -0
  18. package/types/Pagination/PaginationArrowButton/__new-tests__/PaginationArrowButton.test.d.ts.map +1 -0
  19. package/types/Pagination/PaginationButton/__new-tests__/PaginationButton.test.d.ts +2 -0
  20. package/types/Pagination/PaginationButton/__new-tests__/PaginationButton.test.d.ts.map +1 -0
  21. package/types/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.d.ts +2 -0
  22. package/types/Pagination/PaginationPageInput/__new-tests__/PaginationPageInput.test.d.ts.map +1 -0
  23. package/types/Pagination/__new-tests__/Pagination.test.d.ts.map +1 -1
  24. package/es/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.js +0 -38
  25. package/es/Pagination/PaginationArrowButton/locator.js +0 -26
  26. package/es/Pagination/PaginationLocator.js +0 -38
  27. package/es/Pagination/PaginationPageInput/PaginationPageInputLocator.js +0 -36
  28. package/es/Pagination/locator.js +0 -27
  29. package/lib/Pagination/PaginationArrowButton/locator.js +0 -37
  30. package/lib/Pagination/PaginationLocator.js +0 -44
  31. package/lib/Pagination/locator.js +0 -37
  32. package/src/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.ts +0 -43
  33. package/src/Pagination/PaginationArrowButton/locator.ts +0 -27
  34. package/src/Pagination/PaginationLocator.ts +0 -46
  35. package/src/Pagination/locator.ts +0 -28
  36. package/types/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.d.ts +0 -582
  37. package/types/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.d.ts.map +0 -1
  38. package/types/Pagination/PaginationArrowButton/locator.d.ts +0 -4
  39. package/types/Pagination/PaginationArrowButton/locator.d.ts.map +0 -1
  40. package/types/Pagination/PaginationLocator.d.ts +0 -3381
  41. package/types/Pagination/PaginationLocator.d.ts.map +0 -1
  42. package/types/Pagination/PaginationPageInput/PaginationPageInputLocator.d.ts +0 -581
  43. package/types/Pagination/PaginationPageInput/PaginationPageInputLocator.d.ts.map +0 -1
  44. package/types/Pagination/locator.d.ts +0 -4
  45. package/types/Pagination/locator.d.ts.map +0 -1
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PaginationArrowButtonLocator = void 0;
7
- var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
8
- var _uiTestQueries = require("@instructure/ui-test-queries");
9
- var _TooltipLocator = require("@instructure/ui-tooltip/lib/Tooltip/TooltipLocator");
10
- var _index = require("./index");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ require("@testing-library/jest-dom");
7
+ var _index = require("../index");
8
+ var _PaginationArrowButto;
11
9
  /*
12
10
  * The MIT License (MIT)
13
11
  *
@@ -31,15 +29,27 @@ var _index = require("./index");
31
29
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
30
  * SOFTWARE.
33
31
  */
34
-
35
- // @ts-ignore: Cannot find module
36
- // eslint-disable-next-line no-restricted-imports
37
-
38
- const PaginationArrowButtonLocator = exports.PaginationArrowButtonLocator = (0, _locator.locator)(
39
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
40
- _index.PaginationArrowButton.selector, {
41
- findTooltipContent: (...args) => _TooltipLocator.TooltipLocator.findContent(...args),
42
- click: async (element, ...args) => {
43
- return (await (0, _uiTestQueries.find)(element, 'a,button,[role="button"]')).click(...args);
44
- }
32
+ describe('<PaginationArrowButton />', () => {
33
+ it('should render', async () => {
34
+ (0, _react2.render)(_PaginationArrowButto || (_PaginationArrowButto = /*#__PURE__*/_react.default.createElement(_index.PaginationArrowButton, {
35
+ direction: "prev",
36
+ label: "Label"
37
+ })));
38
+ const button = _react2.screen.getByRole('button', {
39
+ name: 'Label'
40
+ });
41
+ expect(button).toBeInTheDocument();
42
+ });
43
+ it('should provide a ref to the button element', async () => {
44
+ const buttonRef = jest.fn();
45
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationArrowButton, {
46
+ direction: "prev",
47
+ label: "Label",
48
+ buttonRef: buttonRef
49
+ }));
50
+ const button = _react2.screen.getByRole('button', {
51
+ name: 'Label'
52
+ });
53
+ expect(buttonRef).toHaveBeenCalledWith(button);
54
+ });
45
55
  });
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ require("@testing-library/jest-dom");
7
+ var _index = require("../index");
8
+ var _PaginationButton, _PaginationButton2;
9
+ /*
10
+ * The MIT License (MIT)
11
+ *
12
+ * Copyright (c) 2015 - present Instructure, Inc.
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ * of this software and associated documentation files (the "Software"), to deal
16
+ * in the Software without restriction, including without limitation the rights
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ * copies of the Software, and to permit persons to whom the Software is
19
+ * furnished to do so, subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all
22
+ * copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ * SOFTWARE.
31
+ */
32
+ describe('<PaginationButton />', () => {
33
+ it('should designate current page', async () => {
34
+ (0, _react2.render)(_PaginationButton || (_PaginationButton = /*#__PURE__*/_react.default.createElement(_index.PaginationButton, {
35
+ current: true
36
+ }, "1")));
37
+ const button = _react2.screen.getByRole('button', {
38
+ name: '1'
39
+ });
40
+ expect(button).toHaveAttribute('aria-current', 'page');
41
+ });
42
+ it('should navigate using button when onClick provided', async () => {
43
+ const onClick = jest.fn();
44
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationButton, {
45
+ onClick: onClick
46
+ }, "1"));
47
+ const button = _react2.screen.getByRole('button', {
48
+ name: '1'
49
+ });
50
+ button.click();
51
+ await (0, _react2.waitFor)(() => {
52
+ expect(onClick).toHaveBeenCalled();
53
+ });
54
+ });
55
+ it('should disable navigation to current page', async () => {
56
+ const onClick = jest.fn();
57
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationButton, {
58
+ onClick: onClick,
59
+ current: true
60
+ }, "1"));
61
+ const button = _react2.screen.getByRole('button', {
62
+ name: '1'
63
+ });
64
+ button.click();
65
+ await (0, _react2.waitFor)(() => {
66
+ expect(onClick).not.toHaveBeenCalled();
67
+ });
68
+ });
69
+ it('should navigate using link when href provided', async () => {
70
+ (0, _react2.render)(_PaginationButton2 || (_PaginationButton2 = /*#__PURE__*/_react.default.createElement(_index.PaginationButton, {
71
+ href: "https://instructure.design/"
72
+ }, "1")));
73
+ const button = _react2.screen.getByRole('link');
74
+ expect(button).toHaveAttribute('href', 'https://instructure.design/');
75
+ });
76
+ });
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ require("@testing-library/jest-dom");
7
+ var _index = require("../index");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ const defaultSRLabel = (currentPage, numberOfPages) => `Select page (${currentPage} of ${numberOfPages})`;
33
+ describe('<PaginationPageInput />', () => {
34
+ it('should render', async () => {
35
+ const defaultOnChange = jest.fn();
36
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
37
+ numberOfPages: 10,
38
+ currentPageIndex: 0,
39
+ onChange: defaultOnChange,
40
+ screenReaderLabel: defaultSRLabel
41
+ }));
42
+ const input = _react2.screen.getByRole('textbox');
43
+ expect(input).toBeInTheDocument();
44
+ expect(input.tagName).toBe('INPUT');
45
+ });
46
+ it('should display the current page number', async () => {
47
+ const defaultOnChange = jest.fn();
48
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
49
+ numberOfPages: 10,
50
+ currentPageIndex: 3,
51
+ onChange: defaultOnChange,
52
+ screenReaderLabel: defaultSRLabel
53
+ }));
54
+ const input = _react2.screen.getByRole('textbox');
55
+ expect(input).toHaveAttribute('value', '4');
56
+ });
57
+ it('should correctly update page number', async () => {
58
+ const defaultOnChange = jest.fn();
59
+ const _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
60
+ numberOfPages: 10,
61
+ currentPageIndex: 3,
62
+ onChange: defaultOnChange,
63
+ screenReaderLabel: defaultSRLabel
64
+ })),
65
+ rerender = _render.rerender;
66
+ const input = _react2.screen.getByRole('textbox');
67
+ expect(input).toHaveAttribute('value', '4');
68
+
69
+ // Set currentPageIndex: 6
70
+ rerender( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
71
+ numberOfPages: 10,
72
+ currentPageIndex: 6,
73
+ onChange: defaultOnChange,
74
+ screenReaderLabel: defaultSRLabel
75
+ }));
76
+ expect(input).toHaveAttribute('value', '7');
77
+ });
78
+ it("shouldn't display the arrow keys of NumberInput", async () => {
79
+ const defaultOnChange = jest.fn();
80
+ const _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
81
+ numberOfPages: 10,
82
+ currentPageIndex: 3,
83
+ onChange: defaultOnChange,
84
+ screenReaderLabel: defaultSRLabel
85
+ })),
86
+ container = _render2.container;
87
+ const arrowButtons = _react2.screen.queryAllByRole('button');
88
+ expect(arrowButtons.length).toBe(0);
89
+ const arrowKeys = container.querySelectorAll('svg');
90
+ expect(arrowKeys.length).toBe(0);
91
+ });
92
+ it("should disable the input on 'disabled'", async () => {
93
+ const defaultOnChange = jest.fn();
94
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
95
+ numberOfPages: 10,
96
+ currentPageIndex: 3,
97
+ onChange: defaultOnChange,
98
+ screenReaderLabel: defaultSRLabel,
99
+ disabled: true
100
+ }));
101
+ const input = _react2.screen.getByRole('textbox');
102
+ expect(input).toHaveAttribute('disabled');
103
+ });
104
+ it('should set the ScreenReaderLabel for the input', async () => {
105
+ const defaultOnChange = jest.fn();
106
+ const _render3 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
107
+ numberOfPages: 10,
108
+ currentPageIndex: 3,
109
+ onChange: defaultOnChange,
110
+ screenReaderLabel: defaultSRLabel
111
+ })),
112
+ container = _render3.container;
113
+ const label = container.querySelector('label');
114
+ expect(label).toHaveTextContent('Select page (4 of 10)');
115
+ });
116
+ it('should display the number of pages in the label', async () => {
117
+ const defaultOnChange = jest.fn();
118
+ const _render4 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.PaginationPageInput, {
119
+ numberOfPages: 10,
120
+ currentPageIndex: 3,
121
+ onChange: defaultOnChange,
122
+ screenReaderLabel: defaultSRLabel,
123
+ label: numberOfPages => `of ${numberOfPages}`
124
+ })),
125
+ container = _render4.container;
126
+ const label = container.querySelector('label');
127
+ expect(label).toHaveTextContent('of 10');
128
+ });
129
+ });