@instructure/ui-modal 9.2.1-snapshot-0 → 9.2.1-snapshot-2

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 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-0](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-0) (2024-07-09)
6
+ ## [9.2.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-2) (2024-07-10)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-modal
9
9
 
package/README.md CHANGED
@@ -4,8 +4,8 @@ category: packages
4
4
 
5
5
  ## ui-modal
6
6
 
7
- [![npm][npm]][npm-url] 
8
- [![MIT License][license-badge]][license] 
7
+ [![npm][npm]][npm-url]
8
+ [![MIT License][license-badge]][license]
9
9
  [![Code of Conduct][coc-badge]][coc]
10
10
 
11
11
  A component for displaying content in a dialog overlay.
@@ -25,6 +25,7 @@ var _ModalBody, _ModalBody2, _ModalBody3;
25
25
 
26
26
  import React from 'react';
27
27
  import { render } from '@testing-library/react';
28
+ import { vi } from 'vitest';
28
29
  import '@testing-library/jest-dom';
29
30
  import { color2hex } from '@instructure/ui-color-utils';
30
31
  import { canvas } from '@instructure/ui-themes';
@@ -76,7 +77,7 @@ describe('<ModalBody />', () => {
76
77
  allProps.forEach(prop => {
77
78
  if (prop in allowedProps) {
78
79
  it(`should allow the '${prop}' prop`, () => {
79
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
80
+ const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
80
81
  const props = {
81
82
  [prop]: allowedProps[prop]
82
83
  };
@@ -87,7 +88,7 @@ describe('<ModalBody />', () => {
87
88
  } else {
88
89
  it(`should NOT allow the '${prop}' prop`, () => {
89
90
  const expectedErrorMessage = `prop '${prop}' is not allowed.`;
90
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
91
+ const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
91
92
  const props = {
92
93
  [prop]: 'NOT_ALLOWED_VALUE'
93
94
  };
@@ -27,13 +27,32 @@ var _Modal, _Modal2, _Modal$Body, _Modal3, _Modal4, _Modal5, _Modal$Body2, _Moda
27
27
 
28
28
  import React from 'react';
29
29
  import { render, waitFor } from '@testing-library/react';
30
+ import { vi } from 'vitest';
30
31
  import userEvent from '@testing-library/user-event';
31
32
  import '@testing-library/jest-dom';
32
33
  import { Modal } from '../index';
33
34
  describe('<Modal />', () => {
35
+ let consoleWarningMock;
36
+ let consoleErrorMock;
37
+ const originalScroll = window.scroll;
38
+ beforeEach(() => {
39
+ // Mocking console to prevent test output pollution and expect for messages
40
+ consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
41
+ consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
42
+ });
34
43
  afterEach(() => {
35
- jest.clearAllMocks();
36
- jest.restoreAllMocks();
44
+ consoleWarningMock.mockRestore();
45
+ consoleErrorMock.mockRestore();
46
+ });
47
+ beforeAll(() => {
48
+ // Mocking window.scroll to prevent test output pollution
49
+ Object.defineProperty(window, 'scroll', {
50
+ value: vi.fn(),
51
+ writable: true
52
+ });
53
+ });
54
+ afterAll(() => {
55
+ window.scroll = originalScroll;
37
56
  });
38
57
  it('should render nothing and have a node with no parent when closed', () => {
39
58
  const _render = render(_Modal || (_Modal = /*#__PURE__*/React.createElement(Modal, {
@@ -139,9 +158,9 @@ describe('<Modal />', () => {
139
158
  expect(dialog).toHaveAttribute('aria-label', 'Modal Dialog');
140
159
  });
141
160
  it('should use transition', async () => {
142
- const onEnter = jest.fn();
143
- const onEntering = jest.fn();
144
- const onEntered = jest.fn();
161
+ const onEnter = vi.fn();
162
+ const onEntering = vi.fn();
163
+ const onEntered = vi.fn();
145
164
  const _render8 = render( /*#__PURE__*/React.createElement(Modal, {
146
165
  open: true,
147
166
  onEnter: onEnter,
@@ -161,7 +180,7 @@ describe('<Modal />', () => {
161
180
  });
162
181
  });
163
182
  it('should support onOpen prop', async () => {
164
- const onOpen = jest.fn();
183
+ const onOpen = vi.fn();
165
184
  const _render9 = render( /*#__PURE__*/React.createElement(Modal, {
166
185
  open: true,
167
186
  onOpen: onOpen,
@@ -176,7 +195,7 @@ describe('<Modal />', () => {
176
195
  });
177
196
  });
178
197
  it('should support onClose prop', async () => {
179
- const onClose = jest.fn();
198
+ const onClose = vi.fn();
180
199
  const _render10 = render( /*#__PURE__*/React.createElement(Modal, {
181
200
  open: true,
182
201
  onClose: onClose,
@@ -198,7 +217,7 @@ describe('<Modal />', () => {
198
217
  });
199
218
  });
200
219
  it('should dismiss when overlay clicked by default', async () => {
201
- const onDismiss = jest.fn();
220
+ const onDismiss = vi.fn();
202
221
  const _render11 = render( /*#__PURE__*/React.createElement(Modal, {
203
222
  open: true,
204
223
  onDismiss: onDismiss,
@@ -214,8 +233,8 @@ describe('<Modal />', () => {
214
233
  });
215
234
  });
216
235
  it('should NOT dismiss when overlay clicked with shouldCloseOnDocumentClick=false', async () => {
217
- const onDismiss = jest.fn();
218
- const onClickOuter = jest.fn();
236
+ const onDismiss = vi.fn();
237
+ const onClickOuter = vi.fn();
219
238
  const _render12 = render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", {
220
239
  "data-testid": "outer-element",
221
240
  onClick: onClickOuter
@@ -249,7 +268,6 @@ describe('<Modal />', () => {
249
268
  });
250
269
  describe('children validation', () => {
251
270
  it('should pass validation when children are valid', async () => {
252
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
253
271
  const _render14 = render(_Modal7 || (_Modal7 = /*#__PURE__*/React.createElement(Modal, {
254
272
  open: true,
255
273
  label: "Modal Dialog",
@@ -258,11 +276,9 @@ describe('<Modal />', () => {
258
276
  findByRole = _render14.findByRole;
259
277
  const dialog = await findByRole('dialog');
260
278
  expect(dialog).toBeInTheDocument();
261
- expect(consoleErrorSpy).not.toHaveBeenCalled();
262
- consoleErrorSpy.mockRestore();
279
+ expect(consoleErrorMock).not.toHaveBeenCalled();
263
280
  });
264
281
  it('should not pass validation when children are invalid', async () => {
265
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
266
282
  const _render15 = render(_Modal8 || (_Modal8 = /*#__PURE__*/React.createElement(Modal, {
267
283
  open: true,
268
284
  label: "Modal Dialog",
@@ -272,8 +288,7 @@ describe('<Modal />', () => {
272
288
  const dialog = await findByRole('dialog');
273
289
  const expectedErrorMessage = 'Expected children of Modal in one of the following formats:';
274
290
  expect(dialog).toBeInTheDocument();
275
- expect(consoleErrorSpy).toHaveBeenCalledWith(expect.any(String), expect.any(String), expect.stringContaining(expectedErrorMessage), expect.any(String));
276
- consoleErrorSpy.mockRestore();
291
+ expect(consoleErrorMock).toHaveBeenCalledWith(expect.any(String), expect.any(String), expect.stringContaining(expectedErrorMessage), expect.any(String));
277
292
  });
278
293
  it('should pass inverse variant to children when set', async () => {
279
294
  let headerRef = null;
@@ -3,6 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  var _react = _interopRequireDefault(require("react"));
5
5
  var _react2 = require("@testing-library/react");
6
+ var _vitest = require("vitest");
6
7
  require("@testing-library/jest-dom");
7
8
  var _uiColorUtils = require("@instructure/ui-color-utils");
8
9
  var _uiThemes = require("@instructure/ui-themes");
@@ -78,7 +79,7 @@ describe('<ModalBody />', () => {
78
79
  allProps.forEach(prop => {
79
80
  if (prop in allowedProps) {
80
81
  it(`should allow the '${prop}' prop`, () => {
81
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
82
+ const consoleErrorSpy = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
82
83
  const props = {
83
84
  [prop]: allowedProps[prop]
84
85
  };
@@ -89,7 +90,7 @@ describe('<ModalBody />', () => {
89
90
  } else {
90
91
  it(`should NOT allow the '${prop}' prop`, () => {
91
92
  const expectedErrorMessage = `prop '${prop}' is not allowed.`;
92
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
93
+ const consoleErrorSpy = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
93
94
  const props = {
94
95
  [prop]: 'NOT_ALLOWED_VALUE'
95
96
  };
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
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 _index = require("../index");
@@ -33,9 +34,27 @@ var _Modal, _Modal2, _Modal$Body, _Modal3, _Modal4, _Modal5, _Modal$Body2, _Moda
33
34
  * SOFTWARE.
34
35
  */
35
36
  describe('<Modal />', () => {
37
+ let consoleWarningMock;
38
+ let consoleErrorMock;
39
+ const originalScroll = window.scroll;
40
+ beforeEach(() => {
41
+ // Mocking console to prevent test output pollution and expect for messages
42
+ consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
43
+ consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
44
+ });
36
45
  afterEach(() => {
37
- jest.clearAllMocks();
38
- jest.restoreAllMocks();
46
+ consoleWarningMock.mockRestore();
47
+ consoleErrorMock.mockRestore();
48
+ });
49
+ beforeAll(() => {
50
+ // Mocking window.scroll to prevent test output pollution
51
+ Object.defineProperty(window, 'scroll', {
52
+ value: _vitest.vi.fn(),
53
+ writable: true
54
+ });
55
+ });
56
+ afterAll(() => {
57
+ window.scroll = originalScroll;
39
58
  });
40
59
  it('should render nothing and have a node with no parent when closed', () => {
41
60
  const _render = (0, _react2.render)(_Modal || (_Modal = /*#__PURE__*/_react.default.createElement(_index.Modal, {
@@ -141,9 +160,9 @@ describe('<Modal />', () => {
141
160
  expect(dialog).toHaveAttribute('aria-label', 'Modal Dialog');
142
161
  });
143
162
  it('should use transition', async () => {
144
- const onEnter = jest.fn();
145
- const onEntering = jest.fn();
146
- const onEntered = jest.fn();
163
+ const onEnter = _vitest.vi.fn();
164
+ const onEntering = _vitest.vi.fn();
165
+ const onEntered = _vitest.vi.fn();
147
166
  const _render8 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Modal, {
148
167
  open: true,
149
168
  onEnter: onEnter,
@@ -163,7 +182,7 @@ describe('<Modal />', () => {
163
182
  });
164
183
  });
165
184
  it('should support onOpen prop', async () => {
166
- const onOpen = jest.fn();
185
+ const onOpen = _vitest.vi.fn();
167
186
  const _render9 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Modal, {
168
187
  open: true,
169
188
  onOpen: onOpen,
@@ -178,7 +197,7 @@ describe('<Modal />', () => {
178
197
  });
179
198
  });
180
199
  it('should support onClose prop', async () => {
181
- const onClose = jest.fn();
200
+ const onClose = _vitest.vi.fn();
182
201
  const _render10 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Modal, {
183
202
  open: true,
184
203
  onClose: onClose,
@@ -200,7 +219,7 @@ describe('<Modal />', () => {
200
219
  });
201
220
  });
202
221
  it('should dismiss when overlay clicked by default', async () => {
203
- const onDismiss = jest.fn();
222
+ const onDismiss = _vitest.vi.fn();
204
223
  const _render11 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Modal, {
205
224
  open: true,
206
225
  onDismiss: onDismiss,
@@ -216,8 +235,8 @@ describe('<Modal />', () => {
216
235
  });
217
236
  });
218
237
  it('should NOT dismiss when overlay clicked with shouldCloseOnDocumentClick=false', async () => {
219
- const onDismiss = jest.fn();
220
- const onClickOuter = jest.fn();
238
+ const onDismiss = _vitest.vi.fn();
239
+ const onClickOuter = _vitest.vi.fn();
221
240
  const _render12 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("button", {
222
241
  "data-testid": "outer-element",
223
242
  onClick: onClickOuter
@@ -251,7 +270,6 @@ describe('<Modal />', () => {
251
270
  });
252
271
  describe('children validation', () => {
253
272
  it('should pass validation when children are valid', async () => {
254
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
255
273
  const _render14 = (0, _react2.render)(_Modal7 || (_Modal7 = /*#__PURE__*/_react.default.createElement(_index.Modal, {
256
274
  open: true,
257
275
  label: "Modal Dialog",
@@ -260,11 +278,9 @@ describe('<Modal />', () => {
260
278
  findByRole = _render14.findByRole;
261
279
  const dialog = await findByRole('dialog');
262
280
  expect(dialog).toBeInTheDocument();
263
- expect(consoleErrorSpy).not.toHaveBeenCalled();
264
- consoleErrorSpy.mockRestore();
281
+ expect(consoleErrorMock).not.toHaveBeenCalled();
265
282
  });
266
283
  it('should not pass validation when children are invalid', async () => {
267
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
268
284
  const _render15 = (0, _react2.render)(_Modal8 || (_Modal8 = /*#__PURE__*/_react.default.createElement(_index.Modal, {
269
285
  open: true,
270
286
  label: "Modal Dialog",
@@ -274,8 +290,7 @@ describe('<Modal />', () => {
274
290
  const dialog = await findByRole('dialog');
275
291
  const expectedErrorMessage = 'Expected children of Modal in one of the following formats:';
276
292
  expect(dialog).toBeInTheDocument();
277
- expect(consoleErrorSpy).toHaveBeenCalledWith(expect.any(String), expect.any(String), expect.stringContaining(expectedErrorMessage), expect.any(String));
278
- consoleErrorSpy.mockRestore();
293
+ expect(consoleErrorMock).toHaveBeenCalledWith(expect.any(String), expect.any(String), expect.stringContaining(expectedErrorMessage), expect.any(String));
279
294
  });
280
295
  it('should pass inverse variant to children when set', async () => {
281
296
  let headerRef = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-modal",
3
- "version": "9.2.1-snapshot-0",
3
+ "version": "9.2.1-snapshot-2",
4
4
  "description": "A component for displaying content in a dialog overlay",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,33 +24,34 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.24.5",
27
- "@instructure/console": "9.2.1-snapshot-0",
28
- "@instructure/emotion": "9.2.1-snapshot-0",
29
- "@instructure/shared-types": "9.2.1-snapshot-0",
30
- "@instructure/ui-buttons": "9.2.1-snapshot-0",
31
- "@instructure/ui-dialog": "9.2.1-snapshot-0",
32
- "@instructure/ui-dom-utils": "9.2.1-snapshot-0",
33
- "@instructure/ui-motion": "9.2.1-snapshot-0",
34
- "@instructure/ui-overlays": "9.2.1-snapshot-0",
35
- "@instructure/ui-portal": "9.2.1-snapshot-0",
36
- "@instructure/ui-prop-types": "9.2.1-snapshot-0",
37
- "@instructure/ui-react-utils": "9.2.1-snapshot-0",
38
- "@instructure/ui-testable": "9.2.1-snapshot-0",
39
- "@instructure/ui-utils": "9.2.1-snapshot-0",
40
- "@instructure/ui-view": "9.2.1-snapshot-0",
27
+ "@instructure/console": "9.2.1-snapshot-2",
28
+ "@instructure/emotion": "9.2.1-snapshot-2",
29
+ "@instructure/shared-types": "9.2.1-snapshot-2",
30
+ "@instructure/ui-buttons": "9.2.1-snapshot-2",
31
+ "@instructure/ui-dialog": "9.2.1-snapshot-2",
32
+ "@instructure/ui-dom-utils": "9.2.1-snapshot-2",
33
+ "@instructure/ui-motion": "9.2.1-snapshot-2",
34
+ "@instructure/ui-overlays": "9.2.1-snapshot-2",
35
+ "@instructure/ui-portal": "9.2.1-snapshot-2",
36
+ "@instructure/ui-prop-types": "9.2.1-snapshot-2",
37
+ "@instructure/ui-react-utils": "9.2.1-snapshot-2",
38
+ "@instructure/ui-testable": "9.2.1-snapshot-2",
39
+ "@instructure/ui-utils": "9.2.1-snapshot-2",
40
+ "@instructure/ui-view": "9.2.1-snapshot-2",
41
41
  "prop-types": "^15.8.1"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=16.8 <=18"
45
45
  },
46
46
  "devDependencies": {
47
- "@instructure/ui-babel-preset": "9.2.1-snapshot-0",
48
- "@instructure/ui-color-utils": "9.2.1-snapshot-0",
49
- "@instructure/ui-position": "9.2.1-snapshot-0",
50
- "@instructure/ui-themes": "9.2.1-snapshot-0",
47
+ "@instructure/ui-babel-preset": "9.2.1-snapshot-2",
48
+ "@instructure/ui-color-utils": "9.2.1-snapshot-2",
49
+ "@instructure/ui-position": "9.2.1-snapshot-2",
50
+ "@instructure/ui-themes": "9.2.1-snapshot-2",
51
51
  "@testing-library/jest-dom": "^6.4.5",
52
52
  "@testing-library/react": "^15.0.7",
53
- "@testing-library/user-event": "^14.5.2"
53
+ "@testing-library/user-event": "^14.5.2",
54
+ "vitest": "^1.6.0"
54
55
  },
55
56
  "publishConfig": {
56
57
  "access": "public"
@@ -25,6 +25,7 @@
25
25
  import React from 'react'
26
26
 
27
27
  import { render } from '@testing-library/react'
28
+ import { vi } from 'vitest'
28
29
  import '@testing-library/jest-dom'
29
30
 
30
31
  import { color2hex } from '@instructure/ui-color-utils'
@@ -85,7 +86,7 @@ describe('<ModalBody />', () => {
85
86
  allProps.forEach((prop) => {
86
87
  if (prop in allowedProps) {
87
88
  it(`should allow the '${prop}' prop`, () => {
88
- const consoleErrorSpy = jest
89
+ const consoleErrorSpy = vi
89
90
  .spyOn(console, 'error')
90
91
  .mockImplementation(() => {})
91
92
  const props = { [prop]: allowedProps[prop] }
@@ -98,7 +99,7 @@ describe('<ModalBody />', () => {
98
99
  } else {
99
100
  it(`should NOT allow the '${prop}' prop`, () => {
100
101
  const expectedErrorMessage = `prop '${prop}' is not allowed.`
101
- const consoleErrorSpy = jest
102
+ const consoleErrorSpy = vi
102
103
  .spyOn(console, 'error')
103
104
  .mockImplementation(() => {})
104
105
 
@@ -24,6 +24,7 @@
24
24
 
25
25
  import React from 'react'
26
26
  import { render, 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
 
@@ -31,9 +32,35 @@ import { Modal, ModalHeader, ModalBody, ModalFooter } from '../index'
31
32
  import type { ModalProps } from '../props'
32
33
 
33
34
  describe('<Modal />', () => {
35
+ let consoleWarningMock: ReturnType<typeof vi.spyOn>
36
+ let consoleErrorMock: ReturnType<typeof vi.spyOn>
37
+ const originalScroll = window.scroll
38
+
39
+ beforeEach(() => {
40
+ // Mocking console to prevent test output pollution and expect for messages
41
+ consoleWarningMock = vi
42
+ .spyOn(console, 'warn')
43
+ .mockImplementation(() => {}) as any
44
+ consoleErrorMock = vi
45
+ .spyOn(console, 'error')
46
+ .mockImplementation(() => {}) as any
47
+ })
48
+
34
49
  afterEach(() => {
35
- jest.clearAllMocks()
36
- jest.restoreAllMocks()
50
+ consoleWarningMock.mockRestore()
51
+ consoleErrorMock.mockRestore()
52
+ })
53
+
54
+ beforeAll(() => {
55
+ // Mocking window.scroll to prevent test output pollution
56
+ Object.defineProperty(window, 'scroll', {
57
+ value: vi.fn(),
58
+ writable: true
59
+ })
60
+ })
61
+
62
+ afterAll(() => {
63
+ window.scroll = originalScroll
37
64
  })
38
65
 
39
66
  it('should render nothing and have a node with no parent when closed', () => {
@@ -154,9 +181,9 @@ describe('<Modal />', () => {
154
181
  })
155
182
 
156
183
  it('should use transition', async () => {
157
- const onEnter = jest.fn()
158
- const onEntering = jest.fn()
159
- const onEntered = jest.fn()
184
+ const onEnter = vi.fn()
185
+ const onEntering = vi.fn()
186
+ const onEntered = vi.fn()
160
187
 
161
188
  const { findByRole } = render(
162
189
  <Modal
@@ -183,7 +210,7 @@ describe('<Modal />', () => {
183
210
  })
184
211
 
185
212
  it('should support onOpen prop', async () => {
186
- const onOpen = jest.fn()
213
+ const onOpen = vi.fn()
187
214
  const { findByRole } = render(
188
215
  <Modal
189
216
  open
@@ -204,7 +231,7 @@ describe('<Modal />', () => {
204
231
  })
205
232
 
206
233
  it('should support onClose prop', async () => {
207
- const onClose = jest.fn()
234
+ const onClose = vi.fn()
208
235
 
209
236
  const { findByRole, rerender } = render(
210
237
  <Modal
@@ -237,7 +264,7 @@ describe('<Modal />', () => {
237
264
  })
238
265
 
239
266
  it('should dismiss when overlay clicked by default', async () => {
240
- const onDismiss = jest.fn()
267
+ const onDismiss = vi.fn()
241
268
  const { findByText } = render(
242
269
  <Modal
243
270
  open
@@ -259,8 +286,8 @@ describe('<Modal />', () => {
259
286
  })
260
287
 
261
288
  it('should NOT dismiss when overlay clicked with shouldCloseOnDocumentClick=false', async () => {
262
- const onDismiss = jest.fn()
263
- const onClickOuter = jest.fn()
289
+ const onDismiss = vi.fn()
290
+ const onClickOuter = vi.fn()
264
291
 
265
292
  const { findByRole, getByTestId } = render(
266
293
  <div>
@@ -308,10 +335,6 @@ describe('<Modal />', () => {
308
335
 
309
336
  describe('children validation', () => {
310
337
  it('should pass validation when children are valid', async () => {
311
- const consoleErrorSpy = jest
312
- .spyOn(console, 'error')
313
- .mockImplementation(() => {})
314
-
315
338
  const { findByRole } = render(
316
339
  <Modal open label="Modal Dialog" shouldReturnFocus={false}>
317
340
  <Modal.Header>Hello World</Modal.Header>
@@ -324,16 +347,10 @@ describe('<Modal />', () => {
324
347
  const dialog = await findByRole('dialog')
325
348
 
326
349
  expect(dialog).toBeInTheDocument()
327
- expect(consoleErrorSpy).not.toHaveBeenCalled()
328
-
329
- consoleErrorSpy.mockRestore()
350
+ expect(consoleErrorMock).not.toHaveBeenCalled()
330
351
  })
331
352
 
332
353
  it('should not pass validation when children are invalid', async () => {
333
- const consoleErrorSpy = jest
334
- .spyOn(console, 'error')
335
- .mockImplementation(() => {})
336
-
337
354
  const { findByRole } = render(
338
355
  <Modal open label="Modal Dialog" shouldReturnFocus={false}>
339
356
  <Modal.Body>Foo Bar Baz</Modal.Body>
@@ -348,14 +365,12 @@ describe('<Modal />', () => {
348
365
  'Expected children of Modal in one of the following formats:'
349
366
 
350
367
  expect(dialog).toBeInTheDocument()
351
- expect(consoleErrorSpy).toHaveBeenCalledWith(
368
+ expect(consoleErrorMock).toHaveBeenCalledWith(
352
369
  expect.any(String),
353
370
  expect.any(String),
354
371
  expect.stringContaining(expectedErrorMessage),
355
372
  expect.any(String)
356
373
  )
357
-
358
- consoleErrorSpy.mockRestore()
359
374
  })
360
375
 
361
376
  it('should pass inverse variant to children when set', async () => {