@instructure/ui-select 9.2.1-snapshot-1 → 9.2.1-snapshot-3
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/Select/__new-tests__/Select.test.js +19 -18
- package/lib/Select/__new-tests__/Select.test.js +19 -18
- package/package.json +26 -25
- package/src/Select/__new-tests__/Select.test.tsx +24 -21
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Select/__new-tests__/Select.test.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
|
-
## [9.2.1-snapshot-
|
|
6
|
+
## [9.2.1-snapshot-3](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-3) (2024-07-12)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-select
|
|
9
9
|
|
|
@@ -24,6 +24,7 @@ var _Select, _Select2, _Select3, _Select4, _Select5, _Select6, _Select7;
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
27
|
+
import { vi } from 'vitest';
|
|
27
28
|
import userEvent from '@testing-library/user-event';
|
|
28
29
|
import '@testing-library/jest-dom';
|
|
29
30
|
|
|
@@ -42,12 +43,12 @@ const getOptions = (highlighted, selected, disabled) => defaultOptions.map(opt =
|
|
|
42
43
|
isSelected: opt === selected,
|
|
43
44
|
isDisabled: opt === disabled
|
|
44
45
|
}, opt));
|
|
45
|
-
|
|
46
|
-
const originalModule =
|
|
46
|
+
vi.mock('@instructure/ui-utils', async importOriginal => {
|
|
47
|
+
const originalModule = await importOriginal();
|
|
47
48
|
return {
|
|
48
49
|
__esModule: true,
|
|
49
50
|
...originalModule,
|
|
50
|
-
isSafari:
|
|
51
|
+
isSafari: vi.fn(() => true)
|
|
51
52
|
};
|
|
52
53
|
});
|
|
53
54
|
const mockUtils = utils;
|
|
@@ -55,7 +56,7 @@ describe('<Select />', () => {
|
|
|
55
56
|
let consoleErrorMock;
|
|
56
57
|
beforeEach(() => {
|
|
57
58
|
// Mocking console to prevent test output pollution and expect for messages
|
|
58
|
-
consoleErrorMock =
|
|
59
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
59
60
|
});
|
|
60
61
|
afterEach(() => {
|
|
61
62
|
consoleErrorMock.mockRestore();
|
|
@@ -69,7 +70,7 @@ describe('<Select />', () => {
|
|
|
69
70
|
expect(input).toHaveAttribute('role', 'button');
|
|
70
71
|
});
|
|
71
72
|
it('should have role combobox in different browsers than Safari without onInputChange', async () => {
|
|
72
|
-
mockUtils.isSafari =
|
|
73
|
+
mockUtils.isSafari = vi.fn(() => false);
|
|
73
74
|
const _render2 = render( /*#__PURE__*/React.createElement(Select, {
|
|
74
75
|
renderLabel: "Choose an option"
|
|
75
76
|
}, getOptions())),
|
|
@@ -302,7 +303,7 @@ describe('<Select />', () => {
|
|
|
302
303
|
expect(input).toHaveAttribute('autocomplete', 'false');
|
|
303
304
|
});
|
|
304
305
|
it('should provide a ref to the input element', async () => {
|
|
305
|
-
const inputRef =
|
|
306
|
+
const inputRef = vi.fn();
|
|
306
307
|
render( /*#__PURE__*/React.createElement(Select, {
|
|
307
308
|
renderLabel: "Choose an option",
|
|
308
309
|
inputRef: inputRef
|
|
@@ -341,7 +342,7 @@ describe('<Select />', () => {
|
|
|
341
342
|
expect(listbox.tagName).toBe('UL');
|
|
342
343
|
});
|
|
343
344
|
it('should provide a ref to the list element', async () => {
|
|
344
|
-
const listRef =
|
|
345
|
+
const listRef = vi.fn();
|
|
345
346
|
render( /*#__PURE__*/React.createElement(Select, {
|
|
346
347
|
renderLabel: "Choose an option",
|
|
347
348
|
isShowingOptions: true,
|
|
@@ -356,7 +357,7 @@ describe('<Select />', () => {
|
|
|
356
357
|
describe('with callbacks', () => {
|
|
357
358
|
describe('should fire onRequestShowOptions', () => {
|
|
358
359
|
it('when root is clicked', async () => {
|
|
359
|
-
const onRequestShowOptions =
|
|
360
|
+
const onRequestShowOptions = vi.fn();
|
|
360
361
|
const _render8 = render( /*#__PURE__*/React.createElement(Select, {
|
|
361
362
|
renderLabel: "Choose an option",
|
|
362
363
|
onRequestShowOptions: onRequestShowOptions
|
|
@@ -386,7 +387,7 @@ describe('<Select />', () => {
|
|
|
386
387
|
});
|
|
387
388
|
});
|
|
388
389
|
it('when input is clicked', async () => {
|
|
389
|
-
const onRequestShowOptions =
|
|
390
|
+
const onRequestShowOptions = vi.fn();
|
|
390
391
|
const _render9 = render( /*#__PURE__*/React.createElement(Select, {
|
|
391
392
|
renderLabel: "Choose an option",
|
|
392
393
|
onRequestShowOptions: onRequestShowOptions
|
|
@@ -408,7 +409,7 @@ describe('<Select />', () => {
|
|
|
408
409
|
});
|
|
409
410
|
});
|
|
410
411
|
it('when up/down arrows are pressed', async () => {
|
|
411
|
-
const onRequestShowOptions =
|
|
412
|
+
const onRequestShowOptions = vi.fn();
|
|
412
413
|
render( /*#__PURE__*/React.createElement(Select, {
|
|
413
414
|
renderLabel: "Choose an option",
|
|
414
415
|
onRequestShowOptions: onRequestShowOptions
|
|
@@ -424,7 +425,7 @@ describe('<Select />', () => {
|
|
|
424
425
|
});
|
|
425
426
|
});
|
|
426
427
|
it('when space is pressed', async () => {
|
|
427
|
-
const onRequestShowOptions =
|
|
428
|
+
const onRequestShowOptions = vi.fn();
|
|
428
429
|
const _render10 = render( /*#__PURE__*/React.createElement(Select, {
|
|
429
430
|
renderLabel: "Choose an option",
|
|
430
431
|
onRequestShowOptions: onRequestShowOptions
|
|
@@ -448,7 +449,7 @@ describe('<Select />', () => {
|
|
|
448
449
|
});
|
|
449
450
|
describe('should fire onRequestHideOptions', () => {
|
|
450
451
|
it('when root is clicked and isShowingOptions is true', async () => {
|
|
451
|
-
const onRequestHideOptions =
|
|
452
|
+
const onRequestHideOptions = vi.fn();
|
|
452
453
|
const _render11 = render( /*#__PURE__*/React.createElement(Select, {
|
|
453
454
|
renderLabel: "Choose an option",
|
|
454
455
|
isShowingOptions: true,
|
|
@@ -469,7 +470,7 @@ describe('<Select />', () => {
|
|
|
469
470
|
});
|
|
470
471
|
});
|
|
471
472
|
it('when root is clicked and isShowingOptions is false should NOT fire onRequestHideOptions', async () => {
|
|
472
|
-
const onRequestHideOptions =
|
|
473
|
+
const onRequestHideOptions = vi.fn();
|
|
473
474
|
render( /*#__PURE__*/React.createElement(Select, {
|
|
474
475
|
renderLabel: "Choose an option",
|
|
475
476
|
isShowingOptions: false,
|
|
@@ -483,7 +484,7 @@ describe('<Select />', () => {
|
|
|
483
484
|
});
|
|
484
485
|
});
|
|
485
486
|
it('when input is clicked', async () => {
|
|
486
|
-
const onRequestHideOptions =
|
|
487
|
+
const onRequestHideOptions = vi.fn();
|
|
487
488
|
const _render12 = render( /*#__PURE__*/React.createElement(Select, {
|
|
488
489
|
renderLabel: "Choose an option",
|
|
489
490
|
isShowingOptions: true,
|
|
@@ -506,7 +507,7 @@ describe('<Select />', () => {
|
|
|
506
507
|
});
|
|
507
508
|
});
|
|
508
509
|
it('when escape is pressed', async () => {
|
|
509
|
-
const onRequestHideOptions =
|
|
510
|
+
const onRequestHideOptions = vi.fn();
|
|
510
511
|
render( /*#__PURE__*/React.createElement(Select, {
|
|
511
512
|
renderLabel: "Choose an option",
|
|
512
513
|
isShowingOptions: true,
|
|
@@ -521,7 +522,7 @@ describe('<Select />', () => {
|
|
|
521
522
|
});
|
|
522
523
|
describe('should fire onRequestHighlightOption', () => {
|
|
523
524
|
it('when options are hovered', async () => {
|
|
524
|
-
const onRequestHighlightOption =
|
|
525
|
+
const onRequestHighlightOption = vi.fn();
|
|
525
526
|
render( /*#__PURE__*/React.createElement(Select, {
|
|
526
527
|
renderLabel: "Choose an option",
|
|
527
528
|
isShowingOptions: true,
|
|
@@ -544,7 +545,7 @@ describe('<Select />', () => {
|
|
|
544
545
|
});
|
|
545
546
|
describe('input callbacks', () => {
|
|
546
547
|
it('should fire onInputChange when input is typed in', async () => {
|
|
547
|
-
const onInputChange =
|
|
548
|
+
const onInputChange = vi.fn();
|
|
548
549
|
render( /*#__PURE__*/React.createElement(Select, {
|
|
549
550
|
renderLabel: "Choose an option",
|
|
550
551
|
onInputChange: onInputChange
|
|
@@ -556,7 +557,7 @@ describe('<Select />', () => {
|
|
|
556
557
|
});
|
|
557
558
|
});
|
|
558
559
|
it('should fire onFocus when input gains focus', async () => {
|
|
559
|
-
const onFocus =
|
|
560
|
+
const onFocus = vi.fn();
|
|
560
561
|
render( /*#__PURE__*/React.createElement(Select, {
|
|
561
562
|
renderLabel: "Choose an option",
|
|
562
563
|
onFocus: onFocus
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
6
|
var _react2 = require("@testing-library/react");
|
|
7
|
+
var _vitest = require("vitest");
|
|
7
8
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
9
|
require("@testing-library/jest-dom");
|
|
9
10
|
var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yTests");
|
|
@@ -45,12 +46,12 @@ const getOptions = (highlighted, selected, disabled) => defaultOptions.map(opt =
|
|
|
45
46
|
isSelected: opt === selected,
|
|
46
47
|
isDisabled: opt === disabled
|
|
47
48
|
}, opt));
|
|
48
|
-
|
|
49
|
-
const originalModule =
|
|
49
|
+
_vitest.vi.mock('@instructure/ui-utils', async importOriginal => {
|
|
50
|
+
const originalModule = await importOriginal();
|
|
50
51
|
return {
|
|
51
52
|
__esModule: true,
|
|
52
53
|
...originalModule,
|
|
53
|
-
isSafari:
|
|
54
|
+
isSafari: _vitest.vi.fn(() => true)
|
|
54
55
|
};
|
|
55
56
|
});
|
|
56
57
|
const mockUtils = utils;
|
|
@@ -58,7 +59,7 @@ describe('<Select />', () => {
|
|
|
58
59
|
let consoleErrorMock;
|
|
59
60
|
beforeEach(() => {
|
|
60
61
|
// Mocking console to prevent test output pollution and expect for messages
|
|
61
|
-
consoleErrorMock =
|
|
62
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
62
63
|
});
|
|
63
64
|
afterEach(() => {
|
|
64
65
|
consoleErrorMock.mockRestore();
|
|
@@ -72,7 +73,7 @@ describe('<Select />', () => {
|
|
|
72
73
|
expect(input).toHaveAttribute('role', 'button');
|
|
73
74
|
});
|
|
74
75
|
it('should have role combobox in different browsers than Safari without onInputChange', async () => {
|
|
75
|
-
mockUtils.isSafari =
|
|
76
|
+
mockUtils.isSafari = _vitest.vi.fn(() => false);
|
|
76
77
|
const _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
77
78
|
renderLabel: "Choose an option"
|
|
78
79
|
}, getOptions())),
|
|
@@ -305,7 +306,7 @@ describe('<Select />', () => {
|
|
|
305
306
|
expect(input).toHaveAttribute('autocomplete', 'false');
|
|
306
307
|
});
|
|
307
308
|
it('should provide a ref to the input element', async () => {
|
|
308
|
-
const inputRef =
|
|
309
|
+
const inputRef = _vitest.vi.fn();
|
|
309
310
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
310
311
|
renderLabel: "Choose an option",
|
|
311
312
|
inputRef: inputRef
|
|
@@ -344,7 +345,7 @@ describe('<Select />', () => {
|
|
|
344
345
|
expect(listbox.tagName).toBe('UL');
|
|
345
346
|
});
|
|
346
347
|
it('should provide a ref to the list element', async () => {
|
|
347
|
-
const listRef =
|
|
348
|
+
const listRef = _vitest.vi.fn();
|
|
348
349
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
349
350
|
renderLabel: "Choose an option",
|
|
350
351
|
isShowingOptions: true,
|
|
@@ -359,7 +360,7 @@ describe('<Select />', () => {
|
|
|
359
360
|
describe('with callbacks', () => {
|
|
360
361
|
describe('should fire onRequestShowOptions', () => {
|
|
361
362
|
it('when root is clicked', async () => {
|
|
362
|
-
const onRequestShowOptions =
|
|
363
|
+
const onRequestShowOptions = _vitest.vi.fn();
|
|
363
364
|
const _render8 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
364
365
|
renderLabel: "Choose an option",
|
|
365
366
|
onRequestShowOptions: onRequestShowOptions
|
|
@@ -389,7 +390,7 @@ describe('<Select />', () => {
|
|
|
389
390
|
});
|
|
390
391
|
});
|
|
391
392
|
it('when input is clicked', async () => {
|
|
392
|
-
const onRequestShowOptions =
|
|
393
|
+
const onRequestShowOptions = _vitest.vi.fn();
|
|
393
394
|
const _render9 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
394
395
|
renderLabel: "Choose an option",
|
|
395
396
|
onRequestShowOptions: onRequestShowOptions
|
|
@@ -411,7 +412,7 @@ describe('<Select />', () => {
|
|
|
411
412
|
});
|
|
412
413
|
});
|
|
413
414
|
it('when up/down arrows are pressed', async () => {
|
|
414
|
-
const onRequestShowOptions =
|
|
415
|
+
const onRequestShowOptions = _vitest.vi.fn();
|
|
415
416
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
416
417
|
renderLabel: "Choose an option",
|
|
417
418
|
onRequestShowOptions: onRequestShowOptions
|
|
@@ -427,7 +428,7 @@ describe('<Select />', () => {
|
|
|
427
428
|
});
|
|
428
429
|
});
|
|
429
430
|
it('when space is pressed', async () => {
|
|
430
|
-
const onRequestShowOptions =
|
|
431
|
+
const onRequestShowOptions = _vitest.vi.fn();
|
|
431
432
|
const _render10 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
432
433
|
renderLabel: "Choose an option",
|
|
433
434
|
onRequestShowOptions: onRequestShowOptions
|
|
@@ -451,7 +452,7 @@ describe('<Select />', () => {
|
|
|
451
452
|
});
|
|
452
453
|
describe('should fire onRequestHideOptions', () => {
|
|
453
454
|
it('when root is clicked and isShowingOptions is true', async () => {
|
|
454
|
-
const onRequestHideOptions =
|
|
455
|
+
const onRequestHideOptions = _vitest.vi.fn();
|
|
455
456
|
const _render11 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
456
457
|
renderLabel: "Choose an option",
|
|
457
458
|
isShowingOptions: true,
|
|
@@ -472,7 +473,7 @@ describe('<Select />', () => {
|
|
|
472
473
|
});
|
|
473
474
|
});
|
|
474
475
|
it('when root is clicked and isShowingOptions is false should NOT fire onRequestHideOptions', async () => {
|
|
475
|
-
const onRequestHideOptions =
|
|
476
|
+
const onRequestHideOptions = _vitest.vi.fn();
|
|
476
477
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
477
478
|
renderLabel: "Choose an option",
|
|
478
479
|
isShowingOptions: false,
|
|
@@ -486,7 +487,7 @@ describe('<Select />', () => {
|
|
|
486
487
|
});
|
|
487
488
|
});
|
|
488
489
|
it('when input is clicked', async () => {
|
|
489
|
-
const onRequestHideOptions =
|
|
490
|
+
const onRequestHideOptions = _vitest.vi.fn();
|
|
490
491
|
const _render12 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
491
492
|
renderLabel: "Choose an option",
|
|
492
493
|
isShowingOptions: true,
|
|
@@ -509,7 +510,7 @@ describe('<Select />', () => {
|
|
|
509
510
|
});
|
|
510
511
|
});
|
|
511
512
|
it('when escape is pressed', async () => {
|
|
512
|
-
const onRequestHideOptions =
|
|
513
|
+
const onRequestHideOptions = _vitest.vi.fn();
|
|
513
514
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
514
515
|
renderLabel: "Choose an option",
|
|
515
516
|
isShowingOptions: true,
|
|
@@ -524,7 +525,7 @@ describe('<Select />', () => {
|
|
|
524
525
|
});
|
|
525
526
|
describe('should fire onRequestHighlightOption', () => {
|
|
526
527
|
it('when options are hovered', async () => {
|
|
527
|
-
const onRequestHighlightOption =
|
|
528
|
+
const onRequestHighlightOption = _vitest.vi.fn();
|
|
528
529
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
529
530
|
renderLabel: "Choose an option",
|
|
530
531
|
isShowingOptions: true,
|
|
@@ -547,7 +548,7 @@ describe('<Select />', () => {
|
|
|
547
548
|
});
|
|
548
549
|
describe('input callbacks', () => {
|
|
549
550
|
it('should fire onInputChange when input is typed in', async () => {
|
|
550
|
-
const onInputChange =
|
|
551
|
+
const onInputChange = _vitest.vi.fn();
|
|
551
552
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
552
553
|
renderLabel: "Choose an option",
|
|
553
554
|
onInputChange: onInputChange
|
|
@@ -559,7 +560,7 @@ describe('<Select />', () => {
|
|
|
559
560
|
});
|
|
560
561
|
});
|
|
561
562
|
it('should fire onFocus when input gains focus', async () => {
|
|
562
|
-
const onFocus =
|
|
563
|
+
const onFocus = _vitest.vi.fn();
|
|
563
564
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
564
565
|
renderLabel: "Choose an option",
|
|
565
566
|
onFocus: onFocus
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-select",
|
|
3
|
-
"version": "9.2.1-snapshot-
|
|
3
|
+
"version": "9.2.1-snapshot-3",
|
|
4
4
|
"description": "A component for select and autocomplete behavior.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,35 +23,36 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "9.2.1-snapshot-
|
|
27
|
-
"@instructure/ui-babel-preset": "9.2.1-snapshot-
|
|
28
|
-
"@instructure/ui-color-utils": "9.2.1-snapshot-
|
|
29
|
-
"@instructure/ui-scripts": "9.2.1-snapshot-
|
|
30
|
-
"@instructure/ui-test-locator": "9.2.1-snapshot-
|
|
31
|
-
"@instructure/ui-test-utils": "9.2.1-snapshot-
|
|
32
|
-
"@instructure/ui-themes": "9.2.1-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "9.2.1-snapshot-3",
|
|
27
|
+
"@instructure/ui-babel-preset": "9.2.1-snapshot-3",
|
|
28
|
+
"@instructure/ui-color-utils": "9.2.1-snapshot-3",
|
|
29
|
+
"@instructure/ui-scripts": "9.2.1-snapshot-3",
|
|
30
|
+
"@instructure/ui-test-locator": "9.2.1-snapshot-3",
|
|
31
|
+
"@instructure/ui-test-utils": "9.2.1-snapshot-3",
|
|
32
|
+
"@instructure/ui-themes": "9.2.1-snapshot-3",
|
|
33
33
|
"@testing-library/jest-dom": "^6.4.5",
|
|
34
34
|
"@testing-library/react": "^15.0.7",
|
|
35
|
-
"@testing-library/user-event": "^14.5.2"
|
|
35
|
+
"@testing-library/user-event": "^14.5.2",
|
|
36
|
+
"vitest": "^1.6.0"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@babel/runtime": "^7.24.5",
|
|
39
|
-
"@instructure/emotion": "9.2.1-snapshot-
|
|
40
|
-
"@instructure/shared-types": "9.2.1-snapshot-
|
|
41
|
-
"@instructure/ui-dom-utils": "9.2.1-snapshot-
|
|
42
|
-
"@instructure/ui-form-field": "9.2.1-snapshot-
|
|
43
|
-
"@instructure/ui-icons": "9.2.1-snapshot-
|
|
44
|
-
"@instructure/ui-options": "9.2.1-snapshot-
|
|
45
|
-
"@instructure/ui-popover": "9.2.1-snapshot-
|
|
46
|
-
"@instructure/ui-position": "9.2.1-snapshot-
|
|
47
|
-
"@instructure/ui-prop-types": "9.2.1-snapshot-
|
|
48
|
-
"@instructure/ui-react-utils": "9.2.1-snapshot-
|
|
49
|
-
"@instructure/ui-selectable": "9.2.1-snapshot-
|
|
50
|
-
"@instructure/ui-testable": "9.2.1-snapshot-
|
|
51
|
-
"@instructure/ui-text-input": "9.2.1-snapshot-
|
|
52
|
-
"@instructure/ui-utils": "9.2.1-snapshot-
|
|
53
|
-
"@instructure/ui-view": "9.2.1-snapshot-
|
|
54
|
-
"@instructure/uid": "9.2.1-snapshot-
|
|
40
|
+
"@instructure/emotion": "9.2.1-snapshot-3",
|
|
41
|
+
"@instructure/shared-types": "9.2.1-snapshot-3",
|
|
42
|
+
"@instructure/ui-dom-utils": "9.2.1-snapshot-3",
|
|
43
|
+
"@instructure/ui-form-field": "9.2.1-snapshot-3",
|
|
44
|
+
"@instructure/ui-icons": "9.2.1-snapshot-3",
|
|
45
|
+
"@instructure/ui-options": "9.2.1-snapshot-3",
|
|
46
|
+
"@instructure/ui-popover": "9.2.1-snapshot-3",
|
|
47
|
+
"@instructure/ui-position": "9.2.1-snapshot-3",
|
|
48
|
+
"@instructure/ui-prop-types": "9.2.1-snapshot-3",
|
|
49
|
+
"@instructure/ui-react-utils": "9.2.1-snapshot-3",
|
|
50
|
+
"@instructure/ui-selectable": "9.2.1-snapshot-3",
|
|
51
|
+
"@instructure/ui-testable": "9.2.1-snapshot-3",
|
|
52
|
+
"@instructure/ui-text-input": "9.2.1-snapshot-3",
|
|
53
|
+
"@instructure/ui-utils": "9.2.1-snapshot-3",
|
|
54
|
+
"@instructure/ui-view": "9.2.1-snapshot-3",
|
|
55
|
+
"@instructure/uid": "9.2.1-snapshot-3",
|
|
55
56
|
"prop-types": "^15.8.1"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import React from 'react'
|
|
25
25
|
import { render, screen, waitFor } from '@testing-library/react'
|
|
26
|
+
import { vi } from 'vitest'
|
|
27
|
+
import type { MockInstance } from 'vitest'
|
|
26
28
|
import userEvent from '@testing-library/user-event'
|
|
27
29
|
import '@testing-library/jest-dom'
|
|
28
30
|
|
|
@@ -53,24 +55,25 @@ const getOptions = (
|
|
|
53
55
|
</Select.Option>
|
|
54
56
|
))
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
const originalModule =
|
|
58
|
-
|
|
58
|
+
vi.mock('@instructure/ui-utils', async (importOriginal) => {
|
|
59
|
+
const originalModule = (await importOriginal()) as any
|
|
59
60
|
return {
|
|
60
61
|
__esModule: true,
|
|
61
62
|
...originalModule,
|
|
62
|
-
isSafari:
|
|
63
|
+
isSafari: vi.fn(() => true)
|
|
63
64
|
}
|
|
64
65
|
})
|
|
65
66
|
|
|
66
|
-
const mockUtils = utils as
|
|
67
|
+
const mockUtils = utils as any
|
|
67
68
|
|
|
68
69
|
describe('<Select />', () => {
|
|
69
|
-
let consoleErrorMock:
|
|
70
|
+
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
70
71
|
|
|
71
72
|
beforeEach(() => {
|
|
72
73
|
// Mocking console to prevent test output pollution and expect for messages
|
|
73
|
-
consoleErrorMock =
|
|
74
|
+
consoleErrorMock = vi
|
|
75
|
+
.spyOn(console, 'error')
|
|
76
|
+
.mockImplementation(() => {}) as MockInstance
|
|
74
77
|
})
|
|
75
78
|
|
|
76
79
|
afterEach(() => {
|
|
@@ -86,7 +89,7 @@ describe('<Select />', () => {
|
|
|
86
89
|
})
|
|
87
90
|
|
|
88
91
|
it('should have role combobox in different browsers than Safari without onInputChange', async () => {
|
|
89
|
-
mockUtils.isSafari =
|
|
92
|
+
mockUtils.isSafari = vi.fn(() => false)
|
|
90
93
|
|
|
91
94
|
const { container } = render(
|
|
92
95
|
<Select renderLabel="Choose an option">{getOptions()}</Select>
|
|
@@ -366,7 +369,7 @@ describe('<Select />', () => {
|
|
|
366
369
|
})
|
|
367
370
|
|
|
368
371
|
it('should provide a ref to the input element', async () => {
|
|
369
|
-
const inputRef =
|
|
372
|
+
const inputRef = vi.fn()
|
|
370
373
|
|
|
371
374
|
render(
|
|
372
375
|
<Select renderLabel="Choose an option" inputRef={inputRef}>
|
|
@@ -419,7 +422,7 @@ describe('<Select />', () => {
|
|
|
419
422
|
})
|
|
420
423
|
|
|
421
424
|
it('should provide a ref to the list element', async () => {
|
|
422
|
-
const listRef =
|
|
425
|
+
const listRef = vi.fn()
|
|
423
426
|
|
|
424
427
|
render(
|
|
425
428
|
<Select
|
|
@@ -442,7 +445,7 @@ describe('<Select />', () => {
|
|
|
442
445
|
describe('with callbacks', () => {
|
|
443
446
|
describe('should fire onRequestShowOptions', () => {
|
|
444
447
|
it('when root is clicked', async () => {
|
|
445
|
-
const onRequestShowOptions =
|
|
448
|
+
const onRequestShowOptions = vi.fn()
|
|
446
449
|
|
|
447
450
|
const { container, rerender } = render(
|
|
448
451
|
<Select
|
|
@@ -486,7 +489,7 @@ describe('<Select />', () => {
|
|
|
486
489
|
})
|
|
487
490
|
|
|
488
491
|
it('when input is clicked', async () => {
|
|
489
|
-
const onRequestShowOptions =
|
|
492
|
+
const onRequestShowOptions = vi.fn()
|
|
490
493
|
|
|
491
494
|
const { rerender } = render(
|
|
492
495
|
<Select
|
|
@@ -521,7 +524,7 @@ describe('<Select />', () => {
|
|
|
521
524
|
})
|
|
522
525
|
|
|
523
526
|
it('when up/down arrows are pressed', async () => {
|
|
524
|
-
const onRequestShowOptions =
|
|
527
|
+
const onRequestShowOptions = vi.fn()
|
|
525
528
|
|
|
526
529
|
render(
|
|
527
530
|
<Select
|
|
@@ -546,7 +549,7 @@ describe('<Select />', () => {
|
|
|
546
549
|
})
|
|
547
550
|
|
|
548
551
|
it('when space is pressed', async () => {
|
|
549
|
-
const onRequestShowOptions =
|
|
552
|
+
const onRequestShowOptions = vi.fn()
|
|
550
553
|
|
|
551
554
|
const { rerender } = render(
|
|
552
555
|
<Select
|
|
@@ -583,7 +586,7 @@ describe('<Select />', () => {
|
|
|
583
586
|
|
|
584
587
|
describe('should fire onRequestHideOptions', () => {
|
|
585
588
|
it('when root is clicked and isShowingOptions is true', async () => {
|
|
586
|
-
const onRequestHideOptions =
|
|
589
|
+
const onRequestHideOptions = vi.fn()
|
|
587
590
|
|
|
588
591
|
const { container } = render(
|
|
589
592
|
<Select
|
|
@@ -613,7 +616,7 @@ describe('<Select />', () => {
|
|
|
613
616
|
})
|
|
614
617
|
|
|
615
618
|
it('when root is clicked and isShowingOptions is false should NOT fire onRequestHideOptions', async () => {
|
|
616
|
-
const onRequestHideOptions =
|
|
619
|
+
const onRequestHideOptions = vi.fn()
|
|
617
620
|
|
|
618
621
|
render(
|
|
619
622
|
<Select
|
|
@@ -636,7 +639,7 @@ describe('<Select />', () => {
|
|
|
636
639
|
})
|
|
637
640
|
|
|
638
641
|
it('when input is clicked', async () => {
|
|
639
|
-
const onRequestHideOptions =
|
|
642
|
+
const onRequestHideOptions = vi.fn()
|
|
640
643
|
|
|
641
644
|
const { rerender } = render(
|
|
642
645
|
<Select
|
|
@@ -671,7 +674,7 @@ describe('<Select />', () => {
|
|
|
671
674
|
})
|
|
672
675
|
|
|
673
676
|
it('when escape is pressed', async () => {
|
|
674
|
-
const onRequestHideOptions =
|
|
677
|
+
const onRequestHideOptions = vi.fn()
|
|
675
678
|
|
|
676
679
|
render(
|
|
677
680
|
<Select
|
|
@@ -694,7 +697,7 @@ describe('<Select />', () => {
|
|
|
694
697
|
|
|
695
698
|
describe('should fire onRequestHighlightOption', () => {
|
|
696
699
|
it('when options are hovered', async () => {
|
|
697
|
-
const onRequestHighlightOption =
|
|
700
|
+
const onRequestHighlightOption = vi.fn()
|
|
698
701
|
|
|
699
702
|
render(
|
|
700
703
|
<Select
|
|
@@ -731,7 +734,7 @@ describe('<Select />', () => {
|
|
|
731
734
|
|
|
732
735
|
describe('input callbacks', () => {
|
|
733
736
|
it('should fire onInputChange when input is typed in', async () => {
|
|
734
|
-
const onInputChange =
|
|
737
|
+
const onInputChange = vi.fn()
|
|
735
738
|
|
|
736
739
|
render(
|
|
737
740
|
<Select renderLabel="Choose an option" onInputChange={onInputChange}>
|
|
@@ -748,7 +751,7 @@ describe('<Select />', () => {
|
|
|
748
751
|
})
|
|
749
752
|
|
|
750
753
|
it('should fire onFocus when input gains focus', async () => {
|
|
751
|
-
const onFocus =
|
|
754
|
+
const onFocus = vi.fn()
|
|
752
755
|
|
|
753
756
|
render(
|
|
754
757
|
<Select renderLabel="Choose an option" onFocus={onFocus}>
|