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

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