@instructure/ui-navigation 9.2.1-snapshot-1 → 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-1](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-1) (2024-07-10)
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-navigation
9
9
 
@@ -25,6 +25,7 @@ var _Item, _Item2, _Item3, _ScreenReaderContent;
25
25
 
26
26
  import React from 'react';
27
27
  import { render, screen, waitFor } from '@testing-library/react';
28
+ import { vi } from 'vitest';
28
29
  import userEvent from '@testing-library/user-event';
29
30
  import '@testing-library/jest-dom';
30
31
  import { runAxeCheck } from '@instructure/ui-axe-check';
@@ -39,6 +40,17 @@ const icon = /*#__PURE__*/React.createElement("svg", {
39
40
  r: "40"
40
41
  }));
41
42
  describe('<AppNav.Item />', () => {
43
+ let consoleWarningMock;
44
+ let consoleErrorMock;
45
+ beforeEach(() => {
46
+ // Mocking console to prevent test output pollution and expect for messages
47
+ consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
48
+ consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
49
+ });
50
+ afterEach(() => {
51
+ consoleWarningMock.mockRestore();
52
+ consoleErrorMock.mockRestore();
53
+ });
42
54
  it('should render label text', async () => {
43
55
  render(_Item || (_Item = /*#__PURE__*/React.createElement(Item, {
44
56
  renderLabel: "Some label",
@@ -76,7 +88,7 @@ describe('<AppNav.Item />', () => {
76
88
  expect(after.tagName).toBe('STRONG');
77
89
  });
78
90
  it('should respond to an onClick event', async () => {
79
- const onClick = jest.fn();
91
+ const onClick = vi.fn();
80
92
  render( /*#__PURE__*/React.createElement(Item, {
81
93
  renderLabel: "Some label",
82
94
  onClick: onClick
@@ -88,7 +100,6 @@ describe('<AppNav.Item />', () => {
88
100
  });
89
101
  });
90
102
  it('should output a console error if icon is used with non-screenreader label text', async () => {
91
- const consoleErrorMock = jest.spyOn(console, 'error').mockImplementation();
92
103
  render( /*#__PURE__*/React.createElement(Item, {
93
104
  renderIcon: icon,
94
105
  renderLabel: "Some label",
@@ -96,7 +107,6 @@ describe('<AppNav.Item />', () => {
96
107
  }));
97
108
  const expectedErrorMessage = 'Warning: [AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.';
98
109
  expect(consoleErrorMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
99
- consoleErrorMock.mockRestore();
100
110
  });
101
111
  it('should meet a11y standards', async () => {
102
112
  const _render2 = render( /*#__PURE__*/React.createElement(Item, {
@@ -24,6 +24,7 @@ var _AppNav, _AppNav$Item, _AppNav2, _AppNav3, _AppNav$Item2, _AppNav$Item3, _Ap
24
24
  */
25
25
  import React from 'react';
26
26
  import { render, screen } from '@testing-library/react';
27
+ import { vi } from 'vitest';
27
28
  import '@testing-library/jest-dom';
28
29
 
29
30
  // eslint-disable-next-line no-restricted-imports
@@ -31,18 +32,14 @@ import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11y
31
32
  import { runAxeCheck } from '@instructure/ui-axe-check';
32
33
  import { AppNav } from '../index';
33
34
  import AppNavExamples from '../__examples__/AppNav.examples';
34
- const originalResizeObserver = global.ResizeObserver;
35
35
  describe('<AppNav />', () => {
36
- beforeAll(() => {
37
- // Mock for ResizeObserver browser API
38
- global.ResizeObserver = jest.fn().mockImplementation(() => ({
39
- observe: jest.fn(),
40
- unobserve: jest.fn(),
41
- disconnect: jest.fn()
42
- }));
36
+ let consoleErrorMock;
37
+ beforeEach(() => {
38
+ // Mocking console to prevent test output pollution
39
+ consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
43
40
  });
44
- afterAll(() => {
45
- global.ResizeObserver = originalResizeObserver;
41
+ afterEach(() => {
42
+ consoleErrorMock.mockRestore();
46
43
  });
47
44
  describe('for a11y', () => {
48
45
  it('should render a nav element with an aria-label', async () => {
@@ -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
  var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
7
8
  require("@testing-library/jest-dom");
8
9
  var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
@@ -41,6 +42,17 @@ const icon = /*#__PURE__*/_react.default.createElement("svg", {
41
42
  r: "40"
42
43
  }));
43
44
  describe('<AppNav.Item />', () => {
45
+ let consoleWarningMock;
46
+ let consoleErrorMock;
47
+ beforeEach(() => {
48
+ // Mocking console to prevent test output pollution and expect for messages
49
+ consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
50
+ consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
51
+ });
52
+ afterEach(() => {
53
+ consoleWarningMock.mockRestore();
54
+ consoleErrorMock.mockRestore();
55
+ });
44
56
  it('should render label text', async () => {
45
57
  (0, _react2.render)(_Item || (_Item = /*#__PURE__*/_react.default.createElement(_index.Item, {
46
58
  renderLabel: "Some label",
@@ -78,7 +90,7 @@ describe('<AppNav.Item />', () => {
78
90
  expect(after.tagName).toBe('STRONG');
79
91
  });
80
92
  it('should respond to an onClick event', async () => {
81
- const onClick = jest.fn();
93
+ const onClick = _vitest.vi.fn();
82
94
  (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Item, {
83
95
  renderLabel: "Some label",
84
96
  onClick: onClick
@@ -90,7 +102,6 @@ describe('<AppNav.Item />', () => {
90
102
  });
91
103
  });
92
104
  it('should output a console error if icon is used with non-screenreader label text', async () => {
93
- const consoleErrorMock = jest.spyOn(console, 'error').mockImplementation();
94
105
  (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Item, {
95
106
  renderIcon: icon,
96
107
  renderLabel: "Some label",
@@ -98,7 +109,6 @@ describe('<AppNav.Item />', () => {
98
109
  }));
99
110
  const expectedErrorMessage = 'Warning: [AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.';
100
111
  expect(consoleErrorMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
101
- consoleErrorMock.mockRestore();
102
112
  });
103
113
  it('should meet a11y standards', async () => {
104
114
  const _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Item, {
@@ -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 _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yTests");
8
9
  var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
@@ -33,18 +34,14 @@ var _AppNav, _AppNav$Item, _AppNav2, _AppNav3, _AppNav$Item2, _AppNav$Item3, _Ap
33
34
  * SOFTWARE.
34
35
  */
35
36
  // eslint-disable-next-line no-restricted-imports
36
- const originalResizeObserver = global.ResizeObserver;
37
37
  describe('<AppNav />', () => {
38
- beforeAll(() => {
39
- // Mock for ResizeObserver browser API
40
- global.ResizeObserver = jest.fn().mockImplementation(() => ({
41
- observe: jest.fn(),
42
- unobserve: jest.fn(),
43
- disconnect: jest.fn()
44
- }));
38
+ let consoleErrorMock;
39
+ beforeEach(() => {
40
+ // Mocking console to prevent test output pollution
41
+ consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
45
42
  });
46
- afterAll(() => {
47
- global.ResizeObserver = originalResizeObserver;
43
+ afterEach(() => {
44
+ consoleErrorMock.mockRestore();
48
45
  });
49
46
  describe('for a11y', () => {
50
47
  it('should render a nav element with an aria-label', async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-navigation",
3
- "version": "9.2.1-snapshot-1",
3
+ "version": "9.2.1-snapshot-2",
4
4
  "description": "Main and application level navigational components",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,36 +23,37 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-axe-check": "9.2.1-snapshot-1",
27
- "@instructure/ui-babel-preset": "9.2.1-snapshot-1",
28
- "@instructure/ui-color-utils": "9.2.1-snapshot-1",
29
- "@instructure/ui-scripts": "9.2.1-snapshot-1",
30
- "@instructure/ui-test-utils": "9.2.1-snapshot-1",
31
- "@instructure/ui-themes": "9.2.1-snapshot-1",
26
+ "@instructure/ui-axe-check": "9.2.1-snapshot-2",
27
+ "@instructure/ui-babel-preset": "9.2.1-snapshot-2",
28
+ "@instructure/ui-color-utils": "9.2.1-snapshot-2",
29
+ "@instructure/ui-scripts": "9.2.1-snapshot-2",
30
+ "@instructure/ui-test-utils": "9.2.1-snapshot-2",
31
+ "@instructure/ui-themes": "9.2.1-snapshot-2",
32
32
  "@testing-library/jest-dom": "^6.4.5",
33
33
  "@testing-library/react": "^15.0.7",
34
- "@testing-library/user-event": "^14.5.2"
34
+ "@testing-library/user-event": "^14.5.2",
35
+ "vitest": "^1.6.0"
35
36
  },
36
37
  "dependencies": {
37
38
  "@babel/runtime": "^7.24.5",
38
- "@instructure/console": "9.2.1-snapshot-1",
39
- "@instructure/debounce": "9.2.1-snapshot-1",
40
- "@instructure/emotion": "9.2.1-snapshot-1",
41
- "@instructure/shared-types": "9.2.1-snapshot-1",
42
- "@instructure/ui-a11y-content": "9.2.1-snapshot-1",
43
- "@instructure/ui-a11y-utils": "9.2.1-snapshot-1",
44
- "@instructure/ui-badge": "9.2.1-snapshot-1",
45
- "@instructure/ui-dom-utils": "9.2.1-snapshot-1",
46
- "@instructure/ui-focusable": "9.2.1-snapshot-1",
47
- "@instructure/ui-icons": "9.2.1-snapshot-1",
48
- "@instructure/ui-menu": "9.2.1-snapshot-1",
49
- "@instructure/ui-prop-types": "9.2.1-snapshot-1",
50
- "@instructure/ui-react-utils": "9.2.1-snapshot-1",
51
- "@instructure/ui-testable": "9.2.1-snapshot-1",
52
- "@instructure/ui-tooltip": "9.2.1-snapshot-1",
53
- "@instructure/ui-truncate-list": "9.2.1-snapshot-1",
54
- "@instructure/ui-utils": "9.2.1-snapshot-1",
55
- "@instructure/ui-view": "9.2.1-snapshot-1",
39
+ "@instructure/console": "9.2.1-snapshot-2",
40
+ "@instructure/debounce": "9.2.1-snapshot-2",
41
+ "@instructure/emotion": "9.2.1-snapshot-2",
42
+ "@instructure/shared-types": "9.2.1-snapshot-2",
43
+ "@instructure/ui-a11y-content": "9.2.1-snapshot-2",
44
+ "@instructure/ui-a11y-utils": "9.2.1-snapshot-2",
45
+ "@instructure/ui-badge": "9.2.1-snapshot-2",
46
+ "@instructure/ui-dom-utils": "9.2.1-snapshot-2",
47
+ "@instructure/ui-focusable": "9.2.1-snapshot-2",
48
+ "@instructure/ui-icons": "9.2.1-snapshot-2",
49
+ "@instructure/ui-menu": "9.2.1-snapshot-2",
50
+ "@instructure/ui-prop-types": "9.2.1-snapshot-2",
51
+ "@instructure/ui-react-utils": "9.2.1-snapshot-2",
52
+ "@instructure/ui-testable": "9.2.1-snapshot-2",
53
+ "@instructure/ui-tooltip": "9.2.1-snapshot-2",
54
+ "@instructure/ui-truncate-list": "9.2.1-snapshot-2",
55
+ "@instructure/ui-utils": "9.2.1-snapshot-2",
56
+ "@instructure/ui-view": "9.2.1-snapshot-2",
56
57
  "prop-types": "^15.8.1"
57
58
  },
58
59
  "peerDependencies": {
@@ -25,6 +25,7 @@
25
25
  import React from 'react'
26
26
 
27
27
  import { render, screen, waitFor } from '@testing-library/react'
28
+ import { vi } from 'vitest'
28
29
  import userEvent from '@testing-library/user-event'
29
30
  import '@testing-library/jest-dom'
30
31
 
@@ -40,6 +41,24 @@ const icon = (
40
41
  )
41
42
 
42
43
  describe('<AppNav.Item />', () => {
44
+ let consoleWarningMock: ReturnType<typeof vi.spyOn>
45
+ let consoleErrorMock: ReturnType<typeof vi.spyOn>
46
+
47
+ beforeEach(() => {
48
+ // Mocking console to prevent test output pollution and expect for messages
49
+ consoleWarningMock = vi
50
+ .spyOn(console, 'warn')
51
+ .mockImplementation(() => {}) as any
52
+ consoleErrorMock = vi
53
+ .spyOn(console, 'error')
54
+ .mockImplementation(() => {}) as any
55
+ })
56
+
57
+ afterEach(() => {
58
+ consoleWarningMock.mockRestore()
59
+ consoleErrorMock.mockRestore()
60
+ })
61
+
43
62
  it('should render label text', async () => {
44
63
  render(<Item renderLabel="Some label" href="#" />)
45
64
  const item = screen.getByRole('link')
@@ -86,7 +105,7 @@ describe('<AppNav.Item />', () => {
86
105
  })
87
106
 
88
107
  it('should respond to an onClick event', async () => {
89
- const onClick = jest.fn()
108
+ const onClick = vi.fn()
90
109
  render(<Item renderLabel="Some label" onClick={onClick} />)
91
110
 
92
111
  const button = screen.getByRole('button')
@@ -99,7 +118,6 @@ describe('<AppNav.Item />', () => {
99
118
  })
100
119
 
101
120
  it('should output a console error if icon is used with non-screenreader label text', async () => {
102
- const consoleErrorMock = jest.spyOn(console, 'error').mockImplementation()
103
121
  render(
104
122
  <Item
105
123
  renderIcon={icon}
@@ -115,8 +133,6 @@ describe('<AppNav.Item />', () => {
115
133
  expect.stringContaining(expectedErrorMessage),
116
134
  expect.any(String)
117
135
  )
118
-
119
- consoleErrorMock.mockRestore()
120
136
  })
121
137
 
122
138
  it('should meet a11y standards', async () => {
@@ -23,6 +23,7 @@
23
23
  */
24
24
  import React from 'react'
25
25
  import { render, screen } from '@testing-library/react'
26
+ import { vi } from 'vitest'
26
27
  import '@testing-library/jest-dom'
27
28
 
28
29
  // eslint-disable-next-line no-restricted-imports
@@ -32,20 +33,18 @@ import { runAxeCheck } from '@instructure/ui-axe-check'
32
33
  import { AppNav } from '../index'
33
34
  import AppNavExamples from '../__examples__/AppNav.examples'
34
35
 
35
- const originalResizeObserver = global.ResizeObserver
36
-
37
36
  describe('<AppNav />', () => {
38
- beforeAll(() => {
39
- // Mock for ResizeObserver browser API
40
- global.ResizeObserver = jest.fn().mockImplementation(() => ({
41
- observe: jest.fn(),
42
- unobserve: jest.fn(),
43
- disconnect: jest.fn()
44
- }))
37
+ let consoleErrorMock: ReturnType<typeof vi.spyOn>
38
+
39
+ beforeEach(() => {
40
+ // Mocking console to prevent test output pollution
41
+ consoleErrorMock = vi
42
+ .spyOn(console, 'error')
43
+ .mockImplementation(() => {}) as any
45
44
  })
46
45
 
47
- afterAll(() => {
48
- global.ResizeObserver = originalResizeObserver
46
+ afterEach(() => {
47
+ consoleErrorMock.mockRestore()
49
48
  })
50
49
 
51
50
  describe('for a11y', () => {