@instructure/ui-range-input 10.19.2-snapshot-2 → 10.19.2-snapshot-4

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.
@@ -1,234 +0,0 @@
1
- var _RangeInput, _RangeInput2, _RangeInput3, _RangeInput4, _RangeInput5, _RangeInput6, _RangeInput7, _RangeInput8, _RangeInput9, _RangeInput10, _RangeInput11;
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 { render, screen } from '@testing-library/react';
27
- import { vi, expect } from 'vitest';
28
- import { runAxeCheck } from '@instructure/ui-axe-check';
29
- import '@testing-library/jest-dom';
30
- import { RangeInput } from '../index';
31
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
32
- describe('<RangeInput />', () => {
33
- let consoleWarningMock;
34
- beforeEach(() => {
35
- // Mocking console to prevent test output pollution
36
- consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
37
- });
38
- afterEach(() => {
39
- consoleWarningMock.mockRestore();
40
- });
41
- it('renders an input with type "range"', async () => {
42
- const _render = render(_RangeInput || (_RangeInput = _jsx(RangeInput, {
43
- label: "Opacity",
44
- name: "opacity",
45
- max: 100,
46
- min: 0
47
- }))),
48
- container = _render.container;
49
- const label = container.querySelector('[class$="-formFieldLayout__label"]');
50
- const input = container.querySelector('[class$="-rangeInput__input"]');
51
- expect(label).toBeInTheDocument();
52
- expect(label).toHaveTextContent('Opacity');
53
- expect(input).toBeInTheDocument();
54
- expect(input.tagName).toBe('INPUT');
55
- expect(input).toHaveAttribute('name', 'opacity');
56
- expect(input).toHaveAttribute('type', 'range');
57
- });
58
- it('displays the default value', async () => {
59
- const _render2 = render(_RangeInput2 || (_RangeInput2 = _jsx(RangeInput, {
60
- label: "Opacity",
61
- name: "opacity",
62
- max: 100,
63
- min: 0,
64
- defaultValue: 42
65
- }))),
66
- container = _render2.container;
67
- const output = container.querySelector('[class$="-rangeInput__value"]');
68
- expect(output).toHaveTextContent('42');
69
- });
70
- it('sets input value to default value', async () => {
71
- const _render3 = render(_RangeInput3 || (_RangeInput3 = _jsx(RangeInput, {
72
- label: "Opacity",
73
- name: "opacity",
74
- max: 100,
75
- min: 0,
76
- defaultValue: 25
77
- }))),
78
- container = _render3.container;
79
- const input = container.querySelector('input');
80
- expect(input).toHaveValue('25');
81
- });
82
- it('sets input value to controlled value', async () => {
83
- const _render4 = render(_jsx(RangeInput, {
84
- label: "Opacity",
85
- name: "opacity",
86
- max: 100,
87
- min: 0,
88
- value: 25,
89
- onChange: () => {}
90
- })),
91
- container = _render4.container;
92
- const input = container.querySelector('input');
93
- expect(input).toHaveValue('25');
94
- });
95
- it('should provide an inputRef prop', async () => {
96
- const inputRef = vi.fn();
97
- const _render5 = render(_jsx(RangeInput, {
98
- label: "Opacity",
99
- name: "opacity",
100
- max: 100,
101
- min: 0,
102
- defaultValue: 42,
103
- inputRef: inputRef
104
- })),
105
- container = _render5.container;
106
- const input = container.querySelector('input');
107
- expect(inputRef).toHaveBeenCalledWith(input);
108
- });
109
- describe('thumbVariant prop', () => {
110
- it('should throw deprecation warning by default', async () => {
111
- render(_RangeInput4 || (_RangeInput4 = _jsx(RangeInput, {
112
- label: "Opacity",
113
- name: "opacity",
114
- max: 100,
115
- min: 0,
116
- defaultValue: 30
117
- })));
118
- const expectedErrorMessage = "Warning: [RangeInput] The 'deprecated' value for the `thumbVariant` prop is deprecated. The `deprecated` variant is not fully accessible and will be removed in V9. The connected theme variables will be removed as well: `handleShadowColor`, `handleFocusOutlineColor`, `handleFocusOutlineWidth`. Please use the `accessible` variant.";
119
- expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
120
- });
121
- it('should throw deprecation warning when explicitly "deprecated"', async () => {
122
- render(_RangeInput5 || (_RangeInput5 = _jsx(RangeInput, {
123
- label: "Opacity",
124
- name: "opacity",
125
- max: 100,
126
- min: 0,
127
- defaultValue: 30,
128
- thumbVariant: "deprecated"
129
- })));
130
- const expectedErrorMessage = "Warning: [RangeInput] The 'deprecated' value for the `thumbVariant` prop is deprecated. The `deprecated` variant is not fully accessible and will be removed in V9. The connected theme variables will be removed as well: `handleShadowColor`, `handleFocusOutlineColor`, `handleFocusOutlineWidth`. Please use the `accessible` variant.";
131
- expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
132
- });
133
- it('should not throw deprecation warning when "accessible"', async () => {
134
- render(_RangeInput6 || (_RangeInput6 = _jsx(RangeInput, {
135
- label: "Opacity",
136
- name: "opacity",
137
- max: 100,
138
- min: 0,
139
- defaultValue: 30,
140
- thumbVariant: "accessible"
141
- })));
142
- expect(consoleWarningMock).not.toHaveBeenCalled();
143
- });
144
- });
145
- it('sets min value', async () => {
146
- render(_RangeInput7 || (_RangeInput7 = _jsx(RangeInput, {
147
- label: "Opacity",
148
- name: "opacity",
149
- max: 100,
150
- min: 25
151
- })));
152
- const input = screen.getByLabelText('Opacity');
153
- expect(input).toHaveAttribute('min', '25');
154
- });
155
- it('sets max value', async () => {
156
- render(_RangeInput8 || (_RangeInput8 = _jsx(RangeInput, {
157
- label: "Opacity",
158
- name: "opacity",
159
- max: 75,
160
- min: 0
161
- })));
162
- const input = screen.getByLabelText('Opacity');
163
- expect(input).toHaveAttribute('max', '75');
164
- });
165
- it('sets step value', async () => {
166
- render(_RangeInput9 || (_RangeInput9 = _jsx(RangeInput, {
167
- label: "Opacity",
168
- name: "opacity",
169
- max: 100,
170
- min: 0,
171
- step: 5
172
- })));
173
- const input = screen.getByLabelText('Opacity');
174
- expect(input).toHaveAttribute('step', '5');
175
- });
176
- it('formats the value displayed', async () => {
177
- const _render6 = render(_jsx(RangeInput, {
178
- label: "Opacity",
179
- name: "opacity",
180
- max: 100,
181
- min: 0,
182
- defaultValue: 45,
183
- formatValue: value => {
184
- return `${value}%`;
185
- }
186
- })),
187
- container = _render6.container;
188
- const output = container.querySelector('[class$="-rangeInput__value"]');
189
- expect(output).toHaveTextContent('45%');
190
- });
191
- it('hides the value when displayValue is false', async () => {
192
- const _render7 = render(_RangeInput10 || (_RangeInput10 = _jsx(RangeInput, {
193
- label: "Opacity",
194
- name: "opacity",
195
- max: 100,
196
- min: 0,
197
- displayValue: false
198
- }))),
199
- container = _render7.container;
200
- const output = container.querySelector('[class$="-rangeInput__value"]');
201
- expect(output).not.toBeInTheDocument();
202
- });
203
- describe('for a11y', () => {
204
- it('should meet standards', async () => {
205
- const _render8 = render(_RangeInput11 || (_RangeInput11 = _jsx(RangeInput, {
206
- label: "Opacity",
207
- name: "opacity",
208
- max: 100,
209
- min: 0,
210
- defaultValue: 50
211
- }))),
212
- container = _render8.container;
213
- const axeCheck = await runAxeCheck(container);
214
- expect(axeCheck).toBe(true);
215
- });
216
- it('formats the aria-valuetext attribute', async () => {
217
- const _render9 = render(_jsx(RangeInput, {
218
- label: "Opacity",
219
- name: "opacity",
220
- max: 100,
221
- min: 0,
222
- defaultValue: 40,
223
- formatValue: value => {
224
- return `${value}%`;
225
- }
226
- })),
227
- container = _render9.container;
228
- const input = container.querySelector('input');
229
- const output = container.querySelector('[class$="-rangeInput__value"]');
230
- expect(input).toHaveAttribute('aria-valuetext', '40%');
231
- expect(output).toHaveTextContent('40%');
232
- });
233
- });
234
- });
@@ -1,235 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("@testing-library/react");
4
- var _vitest = require("vitest");
5
- var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
6
- require("@testing-library/jest-dom");
7
- var _index = require("../index");
8
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
9
- var _RangeInput, _RangeInput2, _RangeInput3, _RangeInput4, _RangeInput5, _RangeInput6, _RangeInput7, _RangeInput8, _RangeInput9, _RangeInput10, _RangeInput11;
10
- /*
11
- * The MIT License (MIT)
12
- *
13
- * Copyright (c) 2015 - present Instructure, Inc.
14
- *
15
- * Permission is hereby granted, free of charge, to any person obtaining a copy
16
- * of this software and associated documentation files (the "Software"), to deal
17
- * in the Software without restriction, including without limitation the rights
18
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
- * copies of the Software, and to permit persons to whom the Software is
20
- * furnished to do so, subject to the following conditions:
21
- *
22
- * The above copyright notice and this permission notice shall be included in all
23
- * copies or substantial portions of the Software.
24
- *
25
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
32
- */
33
- describe('<RangeInput />', () => {
34
- let consoleWarningMock;
35
- beforeEach(() => {
36
- // Mocking console to prevent test output pollution
37
- consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
38
- });
39
- afterEach(() => {
40
- consoleWarningMock.mockRestore();
41
- });
42
- it('renders an input with type "range"', async () => {
43
- const _render = (0, _react.render)(_RangeInput || (_RangeInput = (0, _jsxRuntime.jsx)(_index.RangeInput, {
44
- label: "Opacity",
45
- name: "opacity",
46
- max: 100,
47
- min: 0
48
- }))),
49
- container = _render.container;
50
- const label = container.querySelector('[class$="-formFieldLayout__label"]');
51
- const input = container.querySelector('[class$="-rangeInput__input"]');
52
- (0, _vitest.expect)(label).toBeInTheDocument();
53
- (0, _vitest.expect)(label).toHaveTextContent('Opacity');
54
- (0, _vitest.expect)(input).toBeInTheDocument();
55
- (0, _vitest.expect)(input.tagName).toBe('INPUT');
56
- (0, _vitest.expect)(input).toHaveAttribute('name', 'opacity');
57
- (0, _vitest.expect)(input).toHaveAttribute('type', 'range');
58
- });
59
- it('displays the default value', async () => {
60
- const _render2 = (0, _react.render)(_RangeInput2 || (_RangeInput2 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
61
- label: "Opacity",
62
- name: "opacity",
63
- max: 100,
64
- min: 0,
65
- defaultValue: 42
66
- }))),
67
- container = _render2.container;
68
- const output = container.querySelector('[class$="-rangeInput__value"]');
69
- (0, _vitest.expect)(output).toHaveTextContent('42');
70
- });
71
- it('sets input value to default value', async () => {
72
- const _render3 = (0, _react.render)(_RangeInput3 || (_RangeInput3 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
73
- label: "Opacity",
74
- name: "opacity",
75
- max: 100,
76
- min: 0,
77
- defaultValue: 25
78
- }))),
79
- container = _render3.container;
80
- const input = container.querySelector('input');
81
- (0, _vitest.expect)(input).toHaveValue('25');
82
- });
83
- it('sets input value to controlled value', async () => {
84
- const _render4 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.RangeInput, {
85
- label: "Opacity",
86
- name: "opacity",
87
- max: 100,
88
- min: 0,
89
- value: 25,
90
- onChange: () => {}
91
- })),
92
- container = _render4.container;
93
- const input = container.querySelector('input');
94
- (0, _vitest.expect)(input).toHaveValue('25');
95
- });
96
- it('should provide an inputRef prop', async () => {
97
- const inputRef = _vitest.vi.fn();
98
- const _render5 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.RangeInput, {
99
- label: "Opacity",
100
- name: "opacity",
101
- max: 100,
102
- min: 0,
103
- defaultValue: 42,
104
- inputRef: inputRef
105
- })),
106
- container = _render5.container;
107
- const input = container.querySelector('input');
108
- (0, _vitest.expect)(inputRef).toHaveBeenCalledWith(input);
109
- });
110
- describe('thumbVariant prop', () => {
111
- it('should throw deprecation warning by default', async () => {
112
- (0, _react.render)(_RangeInput4 || (_RangeInput4 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
113
- label: "Opacity",
114
- name: "opacity",
115
- max: 100,
116
- min: 0,
117
- defaultValue: 30
118
- })));
119
- const expectedErrorMessage = "Warning: [RangeInput] The 'deprecated' value for the `thumbVariant` prop is deprecated. The `deprecated` variant is not fully accessible and will be removed in V9. The connected theme variables will be removed as well: `handleShadowColor`, `handleFocusOutlineColor`, `handleFocusOutlineWidth`. Please use the `accessible` variant.";
120
- (0, _vitest.expect)(consoleWarningMock).toHaveBeenCalledWith(_vitest.expect.stringContaining(expectedErrorMessage), _vitest.expect.any(String));
121
- });
122
- it('should throw deprecation warning when explicitly "deprecated"', async () => {
123
- (0, _react.render)(_RangeInput5 || (_RangeInput5 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
124
- label: "Opacity",
125
- name: "opacity",
126
- max: 100,
127
- min: 0,
128
- defaultValue: 30,
129
- thumbVariant: "deprecated"
130
- })));
131
- const expectedErrorMessage = "Warning: [RangeInput] The 'deprecated' value for the `thumbVariant` prop is deprecated. The `deprecated` variant is not fully accessible and will be removed in V9. The connected theme variables will be removed as well: `handleShadowColor`, `handleFocusOutlineColor`, `handleFocusOutlineWidth`. Please use the `accessible` variant.";
132
- (0, _vitest.expect)(consoleWarningMock).toHaveBeenCalledWith(_vitest.expect.stringContaining(expectedErrorMessage), _vitest.expect.any(String));
133
- });
134
- it('should not throw deprecation warning when "accessible"', async () => {
135
- (0, _react.render)(_RangeInput6 || (_RangeInput6 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
136
- label: "Opacity",
137
- name: "opacity",
138
- max: 100,
139
- min: 0,
140
- defaultValue: 30,
141
- thumbVariant: "accessible"
142
- })));
143
- (0, _vitest.expect)(consoleWarningMock).not.toHaveBeenCalled();
144
- });
145
- });
146
- it('sets min value', async () => {
147
- (0, _react.render)(_RangeInput7 || (_RangeInput7 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
148
- label: "Opacity",
149
- name: "opacity",
150
- max: 100,
151
- min: 25
152
- })));
153
- const input = _react.screen.getByLabelText('Opacity');
154
- (0, _vitest.expect)(input).toHaveAttribute('min', '25');
155
- });
156
- it('sets max value', async () => {
157
- (0, _react.render)(_RangeInput8 || (_RangeInput8 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
158
- label: "Opacity",
159
- name: "opacity",
160
- max: 75,
161
- min: 0
162
- })));
163
- const input = _react.screen.getByLabelText('Opacity');
164
- (0, _vitest.expect)(input).toHaveAttribute('max', '75');
165
- });
166
- it('sets step value', async () => {
167
- (0, _react.render)(_RangeInput9 || (_RangeInput9 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
168
- label: "Opacity",
169
- name: "opacity",
170
- max: 100,
171
- min: 0,
172
- step: 5
173
- })));
174
- const input = _react.screen.getByLabelText('Opacity');
175
- (0, _vitest.expect)(input).toHaveAttribute('step', '5');
176
- });
177
- it('formats the value displayed', async () => {
178
- const _render6 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.RangeInput, {
179
- label: "Opacity",
180
- name: "opacity",
181
- max: 100,
182
- min: 0,
183
- defaultValue: 45,
184
- formatValue: value => {
185
- return `${value}%`;
186
- }
187
- })),
188
- container = _render6.container;
189
- const output = container.querySelector('[class$="-rangeInput__value"]');
190
- (0, _vitest.expect)(output).toHaveTextContent('45%');
191
- });
192
- it('hides the value when displayValue is false', async () => {
193
- const _render7 = (0, _react.render)(_RangeInput10 || (_RangeInput10 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
194
- label: "Opacity",
195
- name: "opacity",
196
- max: 100,
197
- min: 0,
198
- displayValue: false
199
- }))),
200
- container = _render7.container;
201
- const output = container.querySelector('[class$="-rangeInput__value"]');
202
- (0, _vitest.expect)(output).not.toBeInTheDocument();
203
- });
204
- describe('for a11y', () => {
205
- it('should meet standards', async () => {
206
- const _render8 = (0, _react.render)(_RangeInput11 || (_RangeInput11 = (0, _jsxRuntime.jsx)(_index.RangeInput, {
207
- label: "Opacity",
208
- name: "opacity",
209
- max: 100,
210
- min: 0,
211
- defaultValue: 50
212
- }))),
213
- container = _render8.container;
214
- const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
215
- (0, _vitest.expect)(axeCheck).toBe(true);
216
- });
217
- it('formats the aria-valuetext attribute', async () => {
218
- const _render9 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.RangeInput, {
219
- label: "Opacity",
220
- name: "opacity",
221
- max: 100,
222
- min: 0,
223
- defaultValue: 40,
224
- formatValue: value => {
225
- return `${value}%`;
226
- }
227
- })),
228
- container = _render9.container;
229
- const input = container.querySelector('input');
230
- const output = container.querySelector('[class$="-rangeInput__value"]');
231
- (0, _vitest.expect)(input).toHaveAttribute('aria-valuetext', '40%');
232
- (0, _vitest.expect)(output).toHaveTextContent('40%');
233
- });
234
- });
235
- });