@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-pagination",
3
- "version": "9.0.2-snapshot-9",
3
+ "version": "9.0.2-snapshot-10",
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,32 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "9.0.2-snapshot-9",
27
- "@instructure/ui-test-locator": "9.0.2-snapshot-9",
28
- "@instructure/ui-test-queries": "9.0.2-snapshot-9",
29
- "@instructure/ui-test-utils": "9.0.2-snapshot-9",
26
+ "@instructure/ui-axe-check": "9.0.2-snapshot-10",
27
+ "@instructure/ui-babel-preset": "9.0.2-snapshot-10",
28
+ "@instructure/ui-test-utils": "9.0.2-snapshot-10",
30
29
  "@testing-library/jest-dom": "^6.4.5",
31
- "@testing-library/react": "^15.0.7"
30
+ "@testing-library/react": "^15.0.7",
31
+ "@testing-library/user-event": "^14.5.2"
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.24.5",
35
- "@instructure/emotion": "9.0.2-snapshot-9",
36
- "@instructure/shared-types": "9.0.2-snapshot-9",
37
- "@instructure/ui-a11y-content": "9.0.2-snapshot-9",
38
- "@instructure/ui-a11y-utils": "9.0.2-snapshot-9",
39
- "@instructure/ui-buttons": "9.0.2-snapshot-9",
40
- "@instructure/ui-dom-utils": "9.0.2-snapshot-9",
41
- "@instructure/ui-icons": "9.0.2-snapshot-9",
42
- "@instructure/ui-number-input": "9.0.2-snapshot-9",
43
- "@instructure/ui-portal": "9.0.2-snapshot-9",
44
- "@instructure/ui-prop-types": "9.0.2-snapshot-9",
45
- "@instructure/ui-react-utils": "9.0.2-snapshot-9",
46
- "@instructure/ui-testable": "9.0.2-snapshot-9",
47
- "@instructure/ui-themes": "9.0.2-snapshot-9",
48
- "@instructure/ui-tooltip": "9.0.2-snapshot-9",
49
- "@instructure/ui-utils": "9.0.2-snapshot-9",
50
- "@instructure/ui-view": "9.0.2-snapshot-9",
51
- "@instructure/uid": "9.0.2-snapshot-9",
35
+ "@instructure/emotion": "9.0.2-snapshot-10",
36
+ "@instructure/shared-types": "9.0.2-snapshot-10",
37
+ "@instructure/ui-a11y-content": "9.0.2-snapshot-10",
38
+ "@instructure/ui-a11y-utils": "9.0.2-snapshot-10",
39
+ "@instructure/ui-buttons": "9.0.2-snapshot-10",
40
+ "@instructure/ui-dom-utils": "9.0.2-snapshot-10",
41
+ "@instructure/ui-icons": "9.0.2-snapshot-10",
42
+ "@instructure/ui-number-input": "9.0.2-snapshot-10",
43
+ "@instructure/ui-portal": "9.0.2-snapshot-10",
44
+ "@instructure/ui-prop-types": "9.0.2-snapshot-10",
45
+ "@instructure/ui-react-utils": "9.0.2-snapshot-10",
46
+ "@instructure/ui-testable": "9.0.2-snapshot-10",
47
+ "@instructure/ui-themes": "9.0.2-snapshot-10",
48
+ "@instructure/ui-tooltip": "9.0.2-snapshot-10",
49
+ "@instructure/ui-utils": "9.0.2-snapshot-10",
50
+ "@instructure/ui-view": "9.0.2-snapshot-10",
51
+ "@instructure/uid": "9.0.2-snapshot-10",
52
52
  "prop-types": "^15.8.1"
53
53
  },
54
54
  "peerDependencies": {
@@ -22,21 +22,33 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import { locator } from '@instructure/ui-test-locator'
25
+ import React from 'react'
26
+ import { render, screen } from '@testing-library/react'
26
27
 
27
- // @ts-ignore: Cannot find module
28
- import { NumberInputLocator } from '@instructure/ui-number-input/es/NumberInput/NumberInputLocator' // eslint-disable-line no-restricted-imports
28
+ import '@testing-library/jest-dom'
29
+ import { PaginationArrowButton } from '../index'
29
30
 
30
- import { PaginationPageInput } from './index'
31
+ describe('<PaginationArrowButton />', () => {
32
+ it('should render', async () => {
33
+ render(<PaginationArrowButton direction="prev" label="Label" />)
31
34
 
32
- export const PaginationPageInputLocator = locator(
33
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
34
- PaginationPageInput.selector,
35
+ const button = screen.getByRole('button', { name: 'Label' })
35
36
 
36
- {
37
- findInput: (...args: any[]) => NumberInputLocator.findInput(...args),
37
+ expect(button).toBeInTheDocument()
38
+ })
38
39
 
39
- findNumberInputArrows: (...args: any[]) =>
40
- NumberInputLocator.findArrowButtons(...args)
41
- }
42
- )
40
+ it('should provide a ref to the button element', async () => {
41
+ const buttonRef = jest.fn()
42
+
43
+ render(
44
+ <PaginationArrowButton
45
+ direction="prev"
46
+ label="Label"
47
+ buttonRef={buttonRef}
48
+ />
49
+ )
50
+ const button = screen.getByRole('button', { name: 'Label' })
51
+
52
+ expect(buttonRef).toHaveBeenCalledWith(button)
53
+ })
54
+ })
@@ -0,0 +1,76 @@
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, waitFor } from '@testing-library/react'
27
+
28
+ import '@testing-library/jest-dom'
29
+ import { PaginationButton } from '../index'
30
+
31
+ describe('<PaginationButton />', () => {
32
+ it('should designate current page', async () => {
33
+ render(<PaginationButton current>1</PaginationButton>)
34
+ const button = screen.getByRole('button', { name: '1' })
35
+
36
+ expect(button).toHaveAttribute('aria-current', 'page')
37
+ })
38
+
39
+ it('should navigate using button when onClick provided', async () => {
40
+ const onClick = jest.fn()
41
+ render(<PaginationButton onClick={onClick}>1</PaginationButton>)
42
+
43
+ const button = screen.getByRole('button', { name: '1' })
44
+
45
+ button.click()
46
+
47
+ await waitFor(() => {
48
+ expect(onClick).toHaveBeenCalled()
49
+ })
50
+ })
51
+
52
+ it('should disable navigation to current page', async () => {
53
+ const onClick = jest.fn()
54
+ render(
55
+ <PaginationButton onClick={onClick} current>
56
+ 1
57
+ </PaginationButton>
58
+ )
59
+ const button = screen.getByRole('button', { name: '1' })
60
+
61
+ button.click()
62
+
63
+ await waitFor(() => {
64
+ expect(onClick).not.toHaveBeenCalled()
65
+ })
66
+ })
67
+
68
+ it('should navigate using link when href provided', async () => {
69
+ render(
70
+ <PaginationButton href="https://instructure.design/">1</PaginationButton>
71
+ )
72
+ const button = screen.getByRole('link')
73
+
74
+ expect(button).toHaveAttribute('href', 'https://instructure.design/')
75
+ })
76
+ })
@@ -0,0 +1,155 @@
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
+
28
+ import '@testing-library/jest-dom'
29
+ import { PaginationPageInput } from '../index'
30
+
31
+ const defaultSRLabel = (currentPage: number, numberOfPages: number) =>
32
+ `Select page (${currentPage} of ${numberOfPages})`
33
+
34
+ describe('<PaginationPageInput />', () => {
35
+ it('should render', async () => {
36
+ const defaultOnChange = jest.fn()
37
+ render(
38
+ <PaginationPageInput
39
+ numberOfPages={10}
40
+ currentPageIndex={0}
41
+ onChange={defaultOnChange}
42
+ screenReaderLabel={defaultSRLabel}
43
+ />
44
+ )
45
+ const input = screen.getByRole('textbox')
46
+
47
+ expect(input).toBeInTheDocument()
48
+ expect(input.tagName).toBe('INPUT')
49
+ })
50
+
51
+ it('should display the current page number', async () => {
52
+ const defaultOnChange = jest.fn()
53
+ render(
54
+ <PaginationPageInput
55
+ numberOfPages={10}
56
+ currentPageIndex={3}
57
+ onChange={defaultOnChange}
58
+ screenReaderLabel={defaultSRLabel}
59
+ />
60
+ )
61
+ const input = screen.getByRole('textbox')
62
+
63
+ expect(input).toHaveAttribute('value', '4')
64
+ })
65
+
66
+ it('should correctly update page number', async () => {
67
+ const defaultOnChange = jest.fn()
68
+ const { rerender } = render(
69
+ <PaginationPageInput
70
+ numberOfPages={10}
71
+ currentPageIndex={3}
72
+ onChange={defaultOnChange}
73
+ screenReaderLabel={defaultSRLabel}
74
+ />
75
+ )
76
+ const input = screen.getByRole('textbox')
77
+
78
+ expect(input).toHaveAttribute('value', '4')
79
+
80
+ // Set currentPageIndex: 6
81
+ rerender(
82
+ <PaginationPageInput
83
+ numberOfPages={10}
84
+ currentPageIndex={6}
85
+ onChange={defaultOnChange}
86
+ screenReaderLabel={defaultSRLabel}
87
+ />
88
+ )
89
+ expect(input).toHaveAttribute('value', '7')
90
+ })
91
+
92
+ it("shouldn't display the arrow keys of NumberInput", async () => {
93
+ const defaultOnChange = jest.fn()
94
+ const { container } = render(
95
+ <PaginationPageInput
96
+ numberOfPages={10}
97
+ currentPageIndex={3}
98
+ onChange={defaultOnChange}
99
+ screenReaderLabel={defaultSRLabel}
100
+ />
101
+ )
102
+ const arrowButtons = screen.queryAllByRole('button')
103
+ expect(arrowButtons.length).toBe(0)
104
+
105
+ const arrowKeys = container.querySelectorAll('svg')
106
+ expect(arrowKeys.length).toBe(0)
107
+ })
108
+
109
+ it("should disable the input on 'disabled'", async () => {
110
+ const defaultOnChange = jest.fn()
111
+ render(
112
+ <PaginationPageInput
113
+ numberOfPages={10}
114
+ currentPageIndex={3}
115
+ onChange={defaultOnChange}
116
+ screenReaderLabel={defaultSRLabel}
117
+ disabled
118
+ />
119
+ )
120
+ const input = screen.getByRole('textbox')
121
+
122
+ expect(input).toHaveAttribute('disabled')
123
+ })
124
+
125
+ it('should set the ScreenReaderLabel for the input', async () => {
126
+ const defaultOnChange = jest.fn()
127
+ const { container } = render(
128
+ <PaginationPageInput
129
+ numberOfPages={10}
130
+ currentPageIndex={3}
131
+ onChange={defaultOnChange}
132
+ screenReaderLabel={defaultSRLabel}
133
+ />
134
+ )
135
+ const label = container.querySelector('label')
136
+
137
+ expect(label).toHaveTextContent('Select page (4 of 10)')
138
+ })
139
+
140
+ it('should display the number of pages in the label', async () => {
141
+ const defaultOnChange = jest.fn()
142
+ const { container } = render(
143
+ <PaginationPageInput
144
+ numberOfPages={10}
145
+ currentPageIndex={3}
146
+ onChange={defaultOnChange}
147
+ screenReaderLabel={defaultSRLabel}
148
+ label={(numberOfPages) => `of ${numberOfPages}`}
149
+ />
150
+ )
151
+ const label = container.querySelector('label')
152
+
153
+ expect(label).toHaveTextContent('of 10')
154
+ })
155
+ })