@instructure/ui-buttons 10.2.3-snapshot-14 → 10.2.3-snapshot-15
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/BaseButton/__new-tests__/BaseButton.test.js +16 -16
- package/es/Button/__new-tests__/Button.test.js +18 -18
- package/es/CloseButton/__new-tests__/CloseButton.test.js +1 -1
- package/es/CondensedButton/__new-tests__/CondensedButton.test.js +5 -5
- package/es/IconButton/__new-tests__/IconButton.test.js +4 -4
- package/es/ToggleButton/__new-tests__/ToggleButton.test.js +1 -1
- package/lib/BaseButton/__new-tests__/BaseButton.test.js +16 -16
- package/lib/Button/__new-tests__/Button.test.js +18 -18
- package/lib/CloseButton/__new-tests__/CloseButton.test.js +1 -1
- package/lib/CondensedButton/__new-tests__/CondensedButton.test.js +5 -5
- package/lib/IconButton/__new-tests__/IconButton.test.js +4 -4
- package/lib/ToggleButton/__new-tests__/ToggleButton.test.js +1 -1
- package/package.json +23 -23
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Button/index.d.ts.map +1 -1
- package/types/CloseButton/index.d.ts +4 -4
- package/types/CloseButton/index.d.ts.map +1 -1
- package/types/CondensedButton/index.d.ts.map +1 -1
- package/types/IconButton/index.d.ts.map +1 -1
- package/types/ToggleButton/index.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
|
-
## [10.2.3-snapshot-
|
|
6
|
+
## [10.2.3-snapshot-15](https://github.com/instructure/instructure-ui/compare/v10.2.2...v10.2.3-snapshot-15) (2024-10-03)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-buttons
|
|
9
9
|
|
|
@@ -84,7 +84,7 @@ describe('<BaseButton/>', () => {
|
|
|
84
84
|
});
|
|
85
85
|
it('should set role="button"', () => {
|
|
86
86
|
const onClick = vi.fn();
|
|
87
|
-
const _render3 = render(
|
|
87
|
+
const _render3 = render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
88
88
|
as: "span",
|
|
89
89
|
onClick: onClick
|
|
90
90
|
}, "Hello World")),
|
|
@@ -95,7 +95,7 @@ describe('<BaseButton/>', () => {
|
|
|
95
95
|
});
|
|
96
96
|
it('should set tabIndex="0"', () => {
|
|
97
97
|
const onClick = vi.fn();
|
|
98
|
-
render(
|
|
98
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
99
99
|
as: "span",
|
|
100
100
|
onClick: onClick
|
|
101
101
|
}, "Hello World"));
|
|
@@ -107,7 +107,7 @@ describe('<BaseButton/>', () => {
|
|
|
107
107
|
});
|
|
108
108
|
it('should pass down the type prop to the button element', async () => {
|
|
109
109
|
const onClick = vi.fn();
|
|
110
|
-
render(
|
|
110
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
111
111
|
type: "submit",
|
|
112
112
|
onClick: onClick
|
|
113
113
|
}, "Hello World"));
|
|
@@ -123,7 +123,7 @@ describe('<BaseButton/>', () => {
|
|
|
123
123
|
cy: "75",
|
|
124
124
|
r: "20"
|
|
125
125
|
})));
|
|
126
|
-
render(
|
|
126
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
127
127
|
renderIcon: SomeIcon
|
|
128
128
|
}, "Hello World"));
|
|
129
129
|
const icon = document.querySelector('svg');
|
|
@@ -139,7 +139,7 @@ describe('<BaseButton/>', () => {
|
|
|
139
139
|
});
|
|
140
140
|
it('should provide an elementRef prop', async () => {
|
|
141
141
|
const elementRef = vi.fn();
|
|
142
|
-
render(
|
|
142
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
143
143
|
elementRef: elementRef
|
|
144
144
|
}, "Hello World"));
|
|
145
145
|
const button = screen.getByRole('button', {
|
|
@@ -150,7 +150,7 @@ describe('<BaseButton/>', () => {
|
|
|
150
150
|
describe('onClick', () => {
|
|
151
151
|
it('should call onClick when clicked', async () => {
|
|
152
152
|
const onClick = vi.fn();
|
|
153
|
-
render(
|
|
153
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
154
154
|
onClick: onClick
|
|
155
155
|
}, "Hello World"));
|
|
156
156
|
const button = screen.getByRole('button', {
|
|
@@ -163,7 +163,7 @@ describe('<BaseButton/>', () => {
|
|
|
163
163
|
});
|
|
164
164
|
it('should not call onClick when interaction is "disabled"', async () => {
|
|
165
165
|
const onClick = vi.fn();
|
|
166
|
-
render(
|
|
166
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
167
167
|
interaction: "disabled",
|
|
168
168
|
onClick: onClick
|
|
169
169
|
}, "Hello World"));
|
|
@@ -177,7 +177,7 @@ describe('<BaseButton/>', () => {
|
|
|
177
177
|
});
|
|
178
178
|
it('should not call onClick when disabled is set"', async () => {
|
|
179
179
|
const onClick = vi.fn();
|
|
180
|
-
render(
|
|
180
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
181
181
|
disabled: true,
|
|
182
182
|
onClick: onClick
|
|
183
183
|
}, "Hello World"));
|
|
@@ -191,7 +191,7 @@ describe('<BaseButton/>', () => {
|
|
|
191
191
|
});
|
|
192
192
|
it('should not call onClick when interaction is "readonly"', async () => {
|
|
193
193
|
const onClick = vi.fn();
|
|
194
|
-
render(
|
|
194
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
195
195
|
interaction: "readonly",
|
|
196
196
|
onClick: onClick
|
|
197
197
|
}, "Hello World"));
|
|
@@ -205,7 +205,7 @@ describe('<BaseButton/>', () => {
|
|
|
205
205
|
});
|
|
206
206
|
it('should not call onClick when readOnly is set', async () => {
|
|
207
207
|
const onClick = vi.fn();
|
|
208
|
-
render(
|
|
208
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
209
209
|
readOnly: true,
|
|
210
210
|
onClick: onClick
|
|
211
211
|
}, "Hello World"));
|
|
@@ -232,7 +232,7 @@ describe('<BaseButton/>', () => {
|
|
|
232
232
|
});
|
|
233
233
|
it('should not call onClick when interaction is "readonly" and an href prop is provided', async () => {
|
|
234
234
|
const onClick = vi.fn();
|
|
235
|
-
render(
|
|
235
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
236
236
|
interaction: "readonly",
|
|
237
237
|
onClick: onClick,
|
|
238
238
|
href: "#"
|
|
@@ -247,7 +247,7 @@ describe('<BaseButton/>', () => {
|
|
|
247
247
|
});
|
|
248
248
|
it('should call onClick when space key is pressed if href is provided', async () => {
|
|
249
249
|
const onClick = vi.fn();
|
|
250
|
-
render(
|
|
250
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
251
251
|
onClick: onClick,
|
|
252
252
|
href: "#"
|
|
253
253
|
}, "Hello World"));
|
|
@@ -261,7 +261,7 @@ describe('<BaseButton/>', () => {
|
|
|
261
261
|
});
|
|
262
262
|
it('should call onClick when enter key is pressed when not a button or link', async () => {
|
|
263
263
|
const onClick = vi.fn();
|
|
264
|
-
render(
|
|
264
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
265
265
|
as: "span",
|
|
266
266
|
onClick: onClick
|
|
267
267
|
}, "Hello World"));
|
|
@@ -275,7 +275,7 @@ describe('<BaseButton/>', () => {
|
|
|
275
275
|
});
|
|
276
276
|
it('should not call onClick when interaction is "disabled" and space key is pressed', async () => {
|
|
277
277
|
const onClick = vi.fn();
|
|
278
|
-
render(
|
|
278
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
279
279
|
interaction: "disabled",
|
|
280
280
|
onClick: onClick,
|
|
281
281
|
href: "#"
|
|
@@ -290,7 +290,7 @@ describe('<BaseButton/>', () => {
|
|
|
290
290
|
});
|
|
291
291
|
it('should not call onClick when interaction is "readonly" and space key is pressed', async () => {
|
|
292
292
|
const onClick = vi.fn();
|
|
293
|
-
render(
|
|
293
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
294
294
|
interaction: "readonly",
|
|
295
295
|
onClick: onClick,
|
|
296
296
|
href: "#"
|
|
@@ -327,7 +327,7 @@ describe('<BaseButton/>', () => {
|
|
|
327
327
|
describe('for a11y', () => {
|
|
328
328
|
it('should meet standards when onClick is given', async () => {
|
|
329
329
|
const onClick = vi.fn();
|
|
330
|
-
render(
|
|
330
|
+
render(/*#__PURE__*/React.createElement(BaseButton, {
|
|
331
331
|
onClick: onClick
|
|
332
332
|
}, "Hello World"));
|
|
333
333
|
const button = screen.getByRole('button', {
|
|
@@ -58,7 +58,7 @@ describe('<Button/>', () => {
|
|
|
58
58
|
});
|
|
59
59
|
it('should render children', () => {
|
|
60
60
|
const children = 'Hello world';
|
|
61
|
-
render(
|
|
61
|
+
render(/*#__PURE__*/React.createElement(Button, null, children));
|
|
62
62
|
const button = document.querySelector('button');
|
|
63
63
|
expect(button).toBeInTheDocument();
|
|
64
64
|
expect(button).toHaveTextContent(children);
|
|
@@ -73,7 +73,7 @@ describe('<Button/>', () => {
|
|
|
73
73
|
it('should provide a focused getter', () => {
|
|
74
74
|
var _componentRef;
|
|
75
75
|
let componentRef;
|
|
76
|
-
render(
|
|
76
|
+
render(/*#__PURE__*/React.createElement(Button
|
|
77
77
|
//@ts-expect-error TODO this is coming from ReactComponentWrapper
|
|
78
78
|
, {
|
|
79
79
|
ref: component => {
|
|
@@ -89,7 +89,7 @@ describe('<Button/>', () => {
|
|
|
89
89
|
it('should provide a focus function', () => {
|
|
90
90
|
var _componentRef2;
|
|
91
91
|
let componentRef;
|
|
92
|
-
render(
|
|
92
|
+
render(/*#__PURE__*/React.createElement(Button
|
|
93
93
|
//@ts-expect-error TODO this is coming from ReactComponentWrapper
|
|
94
94
|
, {
|
|
95
95
|
ref: component => {
|
|
@@ -114,7 +114,7 @@ describe('<Button/>', () => {
|
|
|
114
114
|
});
|
|
115
115
|
it('should pass the `elementRef` prop', () => {
|
|
116
116
|
const elementRef = vi.fn();
|
|
117
|
-
render(
|
|
117
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
118
118
|
elementRef: elementRef
|
|
119
119
|
}, "Hello"));
|
|
120
120
|
const button = screen.getByRole('button', {
|
|
@@ -191,7 +191,7 @@ describe('<Button/>', () => {
|
|
|
191
191
|
});
|
|
192
192
|
it('should pass the `onClick` prop', async () => {
|
|
193
193
|
const onClick = vi.fn();
|
|
194
|
-
render(
|
|
194
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
195
195
|
onClick: onClick
|
|
196
196
|
}, "Hello"));
|
|
197
197
|
const button = screen.getByRole('button', {
|
|
@@ -246,7 +246,7 @@ describe('<Button/>', () => {
|
|
|
246
246
|
});
|
|
247
247
|
it('should set role="button"', () => {
|
|
248
248
|
const onClick = vi.fn();
|
|
249
|
-
const _render4 = render(
|
|
249
|
+
const _render4 = render(/*#__PURE__*/React.createElement(Button, {
|
|
250
250
|
as: "span",
|
|
251
251
|
onClick: onClick
|
|
252
252
|
}, "Hello World")),
|
|
@@ -257,7 +257,7 @@ describe('<Button/>', () => {
|
|
|
257
257
|
});
|
|
258
258
|
it('should set tabIndex="0"', () => {
|
|
259
259
|
const onClick = vi.fn();
|
|
260
|
-
render(
|
|
260
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
261
261
|
as: "span",
|
|
262
262
|
onClick: onClick
|
|
263
263
|
}, "Hello World"));
|
|
@@ -267,7 +267,7 @@ describe('<Button/>', () => {
|
|
|
267
267
|
});
|
|
268
268
|
it('should pass down the type prop to the button element', () => {
|
|
269
269
|
const onClick = vi.fn();
|
|
270
|
-
render(
|
|
270
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
271
271
|
type: "submit",
|
|
272
272
|
onClick: onClick
|
|
273
273
|
}, "Hello World"));
|
|
@@ -277,7 +277,7 @@ describe('<Button/>', () => {
|
|
|
277
277
|
});
|
|
278
278
|
it('focuses with the focus helper', () => {
|
|
279
279
|
const onFocus = vi.fn();
|
|
280
|
-
render(
|
|
280
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
281
281
|
onFocus: onFocus
|
|
282
282
|
}, "Hello World"));
|
|
283
283
|
const button = screen.getByRole('button');
|
|
@@ -288,7 +288,7 @@ describe('<Button/>', () => {
|
|
|
288
288
|
describe('onClick', () => {
|
|
289
289
|
it('should call onClick when clicked', async () => {
|
|
290
290
|
const onClick = vi.fn();
|
|
291
|
-
render(
|
|
291
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
292
292
|
onClick: onClick
|
|
293
293
|
}, "Hello World"));
|
|
294
294
|
const button = screen.getByRole('button', {
|
|
@@ -301,7 +301,7 @@ describe('<Button/>', () => {
|
|
|
301
301
|
});
|
|
302
302
|
it('should not call onClick when button is disabled', async () => {
|
|
303
303
|
const onClick = vi.fn();
|
|
304
|
-
render(
|
|
304
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
305
305
|
disabled: true,
|
|
306
306
|
onClick: onClick
|
|
307
307
|
}, "Hello World"));
|
|
@@ -315,7 +315,7 @@ describe('<Button/>', () => {
|
|
|
315
315
|
});
|
|
316
316
|
it('should not call onClick when button is readOnly', async () => {
|
|
317
317
|
const onClick = vi.fn();
|
|
318
|
-
render(
|
|
318
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
319
319
|
readOnly: true,
|
|
320
320
|
onClick: onClick
|
|
321
321
|
}, "Hello World"));
|
|
@@ -342,7 +342,7 @@ describe('<Button/>', () => {
|
|
|
342
342
|
});
|
|
343
343
|
it('should not call onClick when button is readOnly and an href prop is provided', async () => {
|
|
344
344
|
const onClick = vi.fn();
|
|
345
|
-
render(
|
|
345
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
346
346
|
readOnly: true,
|
|
347
347
|
onClick: onClick,
|
|
348
348
|
href: "#"
|
|
@@ -357,7 +357,7 @@ describe('<Button/>', () => {
|
|
|
357
357
|
});
|
|
358
358
|
it('should call onClick when space key is pressed if href is provided', async () => {
|
|
359
359
|
const onClick = vi.fn();
|
|
360
|
-
render(
|
|
360
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
361
361
|
onClick: onClick,
|
|
362
362
|
href: "#"
|
|
363
363
|
}, "Hello World"));
|
|
@@ -371,7 +371,7 @@ describe('<Button/>', () => {
|
|
|
371
371
|
});
|
|
372
372
|
it('should call onClick when enter key is pressed when not a button or link', async () => {
|
|
373
373
|
const onClick = vi.fn();
|
|
374
|
-
render(
|
|
374
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
375
375
|
as: "span",
|
|
376
376
|
onClick: onClick
|
|
377
377
|
}, "Hello World"));
|
|
@@ -385,7 +385,7 @@ describe('<Button/>', () => {
|
|
|
385
385
|
});
|
|
386
386
|
it('should not call onClick when button is disabled and space key is pressed', async () => {
|
|
387
387
|
const onClick = vi.fn();
|
|
388
|
-
render(
|
|
388
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
389
389
|
disabled: true,
|
|
390
390
|
onClick: onClick,
|
|
391
391
|
href: "#"
|
|
@@ -400,7 +400,7 @@ describe('<Button/>', () => {
|
|
|
400
400
|
});
|
|
401
401
|
it('should not call onClick when button is readOnly and space key is pressed', async () => {
|
|
402
402
|
const onClick = vi.fn();
|
|
403
|
-
render(
|
|
403
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
404
404
|
readOnly: true,
|
|
405
405
|
onClick: onClick,
|
|
406
406
|
href: "#"
|
|
@@ -417,7 +417,7 @@ describe('<Button/>', () => {
|
|
|
417
417
|
describe('for a11y', () => {
|
|
418
418
|
it('should meet standards when onClick is given', async () => {
|
|
419
419
|
const onClick = vi.fn();
|
|
420
|
-
render(
|
|
420
|
+
render(/*#__PURE__*/React.createElement(Button, {
|
|
421
421
|
onClick: onClick
|
|
422
422
|
}, "Hello World"));
|
|
423
423
|
const button = screen.getByRole('button', {
|
|
@@ -51,7 +51,7 @@ describe('<CloseButton />', () => {
|
|
|
51
51
|
});
|
|
52
52
|
it('should pass the `onClick` prop', async () => {
|
|
53
53
|
const onClick = vi.fn();
|
|
54
|
-
render(
|
|
54
|
+
render(/*#__PURE__*/React.createElement(CloseButton, {
|
|
55
55
|
onClick: onClick,
|
|
56
56
|
screenReaderLabel: "Hello"
|
|
57
57
|
}));
|
|
@@ -46,7 +46,7 @@ describe('<CondensedButton/>', () => {
|
|
|
46
46
|
const iconSelector = 'svg[data-title="myIcon"]';
|
|
47
47
|
it('should render children', () => {
|
|
48
48
|
const children = 'Hello world';
|
|
49
|
-
render(
|
|
49
|
+
render(/*#__PURE__*/React.createElement(CondensedButton, null, children));
|
|
50
50
|
const button = document.querySelector('button');
|
|
51
51
|
expect(button).toBeInTheDocument();
|
|
52
52
|
expect(button).toHaveTextContent(children);
|
|
@@ -54,7 +54,7 @@ describe('<CondensedButton/>', () => {
|
|
|
54
54
|
it('should provide a focused getter', () => {
|
|
55
55
|
var _componentRef;
|
|
56
56
|
let componentRef;
|
|
57
|
-
render(
|
|
57
|
+
render(/*#__PURE__*/React.createElement(CondensedButton, {
|
|
58
58
|
ref: component => {
|
|
59
59
|
componentRef = component;
|
|
60
60
|
}
|
|
@@ -68,7 +68,7 @@ describe('<CondensedButton/>', () => {
|
|
|
68
68
|
it('should provide a focus function', () => {
|
|
69
69
|
var _componentRef2;
|
|
70
70
|
let componentRef;
|
|
71
|
-
render(
|
|
71
|
+
render(/*#__PURE__*/React.createElement(CondensedButton, {
|
|
72
72
|
ref: component => {
|
|
73
73
|
componentRef = component;
|
|
74
74
|
}
|
|
@@ -91,7 +91,7 @@ describe('<CondensedButton/>', () => {
|
|
|
91
91
|
});
|
|
92
92
|
it('should pass the `elementRef` prop', async () => {
|
|
93
93
|
const elementRef = vi.fn();
|
|
94
|
-
render(
|
|
94
|
+
render(/*#__PURE__*/React.createElement(CondensedButton, {
|
|
95
95
|
elementRef: elementRef
|
|
96
96
|
}, "Hello"));
|
|
97
97
|
const button = screen.getByRole('button', {
|
|
@@ -168,7 +168,7 @@ describe('<CondensedButton/>', () => {
|
|
|
168
168
|
});
|
|
169
169
|
it('should pass the `onClick` prop', async () => {
|
|
170
170
|
const onClick = vi.fn();
|
|
171
|
-
render(
|
|
171
|
+
render(/*#__PURE__*/React.createElement(CondensedButton, {
|
|
172
172
|
onClick: onClick
|
|
173
173
|
}, "Hello"));
|
|
174
174
|
const button = screen.getByRole('button', {
|
|
@@ -67,7 +67,7 @@ describe('<IconButton/>', () => {
|
|
|
67
67
|
it('should provide a focused getter', () => {
|
|
68
68
|
var _componentRef;
|
|
69
69
|
let componentRef;
|
|
70
|
-
render(
|
|
70
|
+
render(/*#__PURE__*/React.createElement(IconButton, {
|
|
71
71
|
screenReaderLabel: "some action",
|
|
72
72
|
renderIcon: icon,
|
|
73
73
|
ref: component => {
|
|
@@ -81,7 +81,7 @@ describe('<IconButton/>', () => {
|
|
|
81
81
|
it('should provide a focus function', () => {
|
|
82
82
|
var _componentRef2;
|
|
83
83
|
let componentRef;
|
|
84
|
-
render(
|
|
84
|
+
render(/*#__PURE__*/React.createElement(IconButton, {
|
|
85
85
|
screenReaderLabel: "some action",
|
|
86
86
|
renderIcon: icon,
|
|
87
87
|
ref: component => {
|
|
@@ -114,7 +114,7 @@ describe('<IconButton/>', () => {
|
|
|
114
114
|
});
|
|
115
115
|
it('should pass the `elementRef` prop', () => {
|
|
116
116
|
const elementRef = vi.fn();
|
|
117
|
-
render(
|
|
117
|
+
render(/*#__PURE__*/React.createElement(IconButton, {
|
|
118
118
|
screenReaderLabel: "some action",
|
|
119
119
|
renderIcon: icon,
|
|
120
120
|
elementRef: elementRef
|
|
@@ -172,7 +172,7 @@ describe('<IconButton/>', () => {
|
|
|
172
172
|
});
|
|
173
173
|
it('should pass the `onClick` prop', async () => {
|
|
174
174
|
const onClick = vi.fn();
|
|
175
|
-
render(
|
|
175
|
+
render(/*#__PURE__*/React.createElement(IconButton, {
|
|
176
176
|
screenReaderLabel: "some action",
|
|
177
177
|
renderIcon: icon,
|
|
178
178
|
onClick: onClick
|
|
@@ -148,7 +148,7 @@ describe('<ToggleButton />', () => {
|
|
|
148
148
|
});
|
|
149
149
|
it('should pass the `onClick` prop', async () => {
|
|
150
150
|
const onClick = vi.fn();
|
|
151
|
-
render(
|
|
151
|
+
render(/*#__PURE__*/React.createElement(ToggleButton, {
|
|
152
152
|
screenReaderLabel: "This is a screen reader label",
|
|
153
153
|
renderIcon: icon,
|
|
154
154
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -86,7 +86,7 @@ describe('<BaseButton/>', () => {
|
|
|
86
86
|
});
|
|
87
87
|
it('should set role="button"', () => {
|
|
88
88
|
const onClick = _vitest.vi.fn();
|
|
89
|
-
const _render3 = (0, _react2.render)(
|
|
89
|
+
const _render3 = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
90
90
|
as: "span",
|
|
91
91
|
onClick: onClick
|
|
92
92
|
}, "Hello World")),
|
|
@@ -97,7 +97,7 @@ describe('<BaseButton/>', () => {
|
|
|
97
97
|
});
|
|
98
98
|
it('should set tabIndex="0"', () => {
|
|
99
99
|
const onClick = _vitest.vi.fn();
|
|
100
|
-
(0, _react2.render)(
|
|
100
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
101
101
|
as: "span",
|
|
102
102
|
onClick: onClick
|
|
103
103
|
}, "Hello World"));
|
|
@@ -109,7 +109,7 @@ describe('<BaseButton/>', () => {
|
|
|
109
109
|
});
|
|
110
110
|
it('should pass down the type prop to the button element', async () => {
|
|
111
111
|
const onClick = _vitest.vi.fn();
|
|
112
|
-
(0, _react2.render)(
|
|
112
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
113
113
|
type: "submit",
|
|
114
114
|
onClick: onClick
|
|
115
115
|
}, "Hello World"));
|
|
@@ -125,7 +125,7 @@ describe('<BaseButton/>', () => {
|
|
|
125
125
|
cy: "75",
|
|
126
126
|
r: "20"
|
|
127
127
|
})));
|
|
128
|
-
(0, _react2.render)(
|
|
128
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
129
129
|
renderIcon: SomeIcon
|
|
130
130
|
}, "Hello World"));
|
|
131
131
|
const icon = document.querySelector('svg');
|
|
@@ -141,7 +141,7 @@ describe('<BaseButton/>', () => {
|
|
|
141
141
|
});
|
|
142
142
|
it('should provide an elementRef prop', async () => {
|
|
143
143
|
const elementRef = _vitest.vi.fn();
|
|
144
|
-
(0, _react2.render)(
|
|
144
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
145
145
|
elementRef: elementRef
|
|
146
146
|
}, "Hello World"));
|
|
147
147
|
const button = _react2.screen.getByRole('button', {
|
|
@@ -152,7 +152,7 @@ describe('<BaseButton/>', () => {
|
|
|
152
152
|
describe('onClick', () => {
|
|
153
153
|
it('should call onClick when clicked', async () => {
|
|
154
154
|
const onClick = _vitest.vi.fn();
|
|
155
|
-
(0, _react2.render)(
|
|
155
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
156
156
|
onClick: onClick
|
|
157
157
|
}, "Hello World"));
|
|
158
158
|
const button = _react2.screen.getByRole('button', {
|
|
@@ -165,7 +165,7 @@ describe('<BaseButton/>', () => {
|
|
|
165
165
|
});
|
|
166
166
|
it('should not call onClick when interaction is "disabled"', async () => {
|
|
167
167
|
const onClick = _vitest.vi.fn();
|
|
168
|
-
(0, _react2.render)(
|
|
168
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
169
169
|
interaction: "disabled",
|
|
170
170
|
onClick: onClick
|
|
171
171
|
}, "Hello World"));
|
|
@@ -179,7 +179,7 @@ describe('<BaseButton/>', () => {
|
|
|
179
179
|
});
|
|
180
180
|
it('should not call onClick when disabled is set"', async () => {
|
|
181
181
|
const onClick = _vitest.vi.fn();
|
|
182
|
-
(0, _react2.render)(
|
|
182
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
183
183
|
disabled: true,
|
|
184
184
|
onClick: onClick
|
|
185
185
|
}, "Hello World"));
|
|
@@ -193,7 +193,7 @@ describe('<BaseButton/>', () => {
|
|
|
193
193
|
});
|
|
194
194
|
it('should not call onClick when interaction is "readonly"', async () => {
|
|
195
195
|
const onClick = _vitest.vi.fn();
|
|
196
|
-
(0, _react2.render)(
|
|
196
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
197
197
|
interaction: "readonly",
|
|
198
198
|
onClick: onClick
|
|
199
199
|
}, "Hello World"));
|
|
@@ -207,7 +207,7 @@ describe('<BaseButton/>', () => {
|
|
|
207
207
|
});
|
|
208
208
|
it('should not call onClick when readOnly is set', async () => {
|
|
209
209
|
const onClick = _vitest.vi.fn();
|
|
210
|
-
(0, _react2.render)(
|
|
210
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
211
211
|
readOnly: true,
|
|
212
212
|
onClick: onClick
|
|
213
213
|
}, "Hello World"));
|
|
@@ -234,7 +234,7 @@ describe('<BaseButton/>', () => {
|
|
|
234
234
|
});
|
|
235
235
|
it('should not call onClick when interaction is "readonly" and an href prop is provided', async () => {
|
|
236
236
|
const onClick = _vitest.vi.fn();
|
|
237
|
-
(0, _react2.render)(
|
|
237
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
238
238
|
interaction: "readonly",
|
|
239
239
|
onClick: onClick,
|
|
240
240
|
href: "#"
|
|
@@ -249,7 +249,7 @@ describe('<BaseButton/>', () => {
|
|
|
249
249
|
});
|
|
250
250
|
it('should call onClick when space key is pressed if href is provided', async () => {
|
|
251
251
|
const onClick = _vitest.vi.fn();
|
|
252
|
-
(0, _react2.render)(
|
|
252
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
253
253
|
onClick: onClick,
|
|
254
254
|
href: "#"
|
|
255
255
|
}, "Hello World"));
|
|
@@ -263,7 +263,7 @@ describe('<BaseButton/>', () => {
|
|
|
263
263
|
});
|
|
264
264
|
it('should call onClick when enter key is pressed when not a button or link', async () => {
|
|
265
265
|
const onClick = _vitest.vi.fn();
|
|
266
|
-
(0, _react2.render)(
|
|
266
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
267
267
|
as: "span",
|
|
268
268
|
onClick: onClick
|
|
269
269
|
}, "Hello World"));
|
|
@@ -277,7 +277,7 @@ describe('<BaseButton/>', () => {
|
|
|
277
277
|
});
|
|
278
278
|
it('should not call onClick when interaction is "disabled" and space key is pressed', async () => {
|
|
279
279
|
const onClick = _vitest.vi.fn();
|
|
280
|
-
(0, _react2.render)(
|
|
280
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
281
281
|
interaction: "disabled",
|
|
282
282
|
onClick: onClick,
|
|
283
283
|
href: "#"
|
|
@@ -292,7 +292,7 @@ describe('<BaseButton/>', () => {
|
|
|
292
292
|
});
|
|
293
293
|
it('should not call onClick when interaction is "readonly" and space key is pressed', async () => {
|
|
294
294
|
const onClick = _vitest.vi.fn();
|
|
295
|
-
(0, _react2.render)(
|
|
295
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
296
296
|
interaction: "readonly",
|
|
297
297
|
onClick: onClick,
|
|
298
298
|
href: "#"
|
|
@@ -329,7 +329,7 @@ describe('<BaseButton/>', () => {
|
|
|
329
329
|
describe('for a11y', () => {
|
|
330
330
|
it('should meet standards when onClick is given', async () => {
|
|
331
331
|
const onClick = _vitest.vi.fn();
|
|
332
|
-
(0, _react2.render)(
|
|
332
|
+
(0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.BaseButton, {
|
|
333
333
|
onClick: onClick
|
|
334
334
|
}, "Hello World"));
|
|
335
335
|
const button = _react2.screen.getByRole('button', {
|