@instructure/ui-side-nav-bar 9.3.1-snapshot-0 → 9.3.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 +1 -1
- package/es/SideNavBar/SideNavBarItem/__new-tests__/NavigationItem.test.js +68 -0
- package/es/SideNavBar/__new-tests__/SideNavBar.test.js +162 -0
- package/lib/SideNavBar/SideNavBarItem/__new-tests__/NavigationItem.test.js +70 -0
- package/lib/SideNavBar/__new-tests__/SideNavBar.test.js +165 -0
- package/package.json +21 -17
- package/src/SideNavBar/SideNavBarItem/__new-tests__/NavigationItem.test.tsx +72 -0
- package/src/SideNavBar/__new-tests__/SideNavBar.test.tsx +209 -0
- package/tsconfig.build.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/SideNavBar/SideNavBarItem/__new-tests__/NavigationItem.test.d.ts +2 -0
- package/types/SideNavBar/SideNavBarItem/__new-tests__/NavigationItem.test.d.ts.map +1 -0
- package/types/SideNavBar/__new-tests__/SideNavBar.test.d.ts +2 -0
- package/types/SideNavBar/__new-tests__/SideNavBar.test.d.ts.map +1 -0
- package/es/SideNavBar/SideNavBarItem/SideNavBarItemLocator.js +0 -33
- package/es/SideNavBar/SideNavBarItem/locator.js +0 -26
- package/es/SideNavBar/SideNavBarLocator.js +0 -37
- package/es/SideNavBar/locator.js +0 -27
- package/lib/SideNavBar/SideNavBarItem/SideNavBarItemLocator.js +0 -40
- package/lib/SideNavBar/SideNavBarItem/locator.js +0 -37
- package/lib/SideNavBar/SideNavBarLocator.js +0 -48
- package/lib/SideNavBar/locator.js +0 -43
- package/src/SideNavBar/SideNavBarItem/SideNavBarItemLocator.ts +0 -34
- package/src/SideNavBar/SideNavBarItem/locator.ts +0 -27
- package/src/SideNavBar/SideNavBarLocator.ts +0 -40
- package/src/SideNavBar/locator.ts +0 -29
- package/types/SideNavBar/SideNavBarItem/SideNavBarItemLocator.d.ts +0 -438
- package/types/SideNavBar/SideNavBarItem/SideNavBarItemLocator.d.ts.map +0 -1
- package/types/SideNavBar/SideNavBarItem/locator.d.ts +0 -4
- package/types/SideNavBar/SideNavBarItem/locator.d.ts.map +0 -1
- package/types/SideNavBar/SideNavBarLocator.d.ts +0 -1845
- package/types/SideNavBar/SideNavBarLocator.d.ts.map +0 -1
- package/types/SideNavBar/locator.d.ts +0 -5
- package/types/SideNavBar/locator.d.ts.map +0 -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.3.1-snapshot-
|
|
6
|
+
## [9.3.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v9.3.0...v9.3.1-snapshot-2) (2024-07-23)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-side-nav-bar
|
|
9
9
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var _SideNavBarItem, _SideNavBarItem2;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { render, screen } from '@testing-library/react';
|
|
28
|
+
import { vi } from 'vitest';
|
|
29
|
+
import '@testing-library/jest-dom';
|
|
30
|
+
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
|
+
import { IconAdminLine } from '@instructure/ui-icons';
|
|
32
|
+
import { SideNavBarItem } from '../index';
|
|
33
|
+
describe('<SideNavBarItem />', () => {
|
|
34
|
+
let consoleErrorMock;
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
// Mocking console to prevent test output pollution
|
|
37
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
38
|
+
});
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
consoleErrorMock.mockRestore();
|
|
41
|
+
});
|
|
42
|
+
it('should render', async () => {
|
|
43
|
+
const _render = render(_SideNavBarItem || (_SideNavBarItem = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
44
|
+
icon: /*#__PURE__*/React.createElement(IconAdminLine, null),
|
|
45
|
+
label: "Admin",
|
|
46
|
+
href: "#"
|
|
47
|
+
}))),
|
|
48
|
+
container = _render.container;
|
|
49
|
+
const navItem = screen.getByRole('link');
|
|
50
|
+
const icon = container.querySelector('svg');
|
|
51
|
+
expect(icon).toBeInTheDocument();
|
|
52
|
+
expect(icon).toHaveAttribute('name', 'IconAdmin');
|
|
53
|
+
expect(navItem).toBeInTheDocument();
|
|
54
|
+
expect(navItem.tagName).toBe('A');
|
|
55
|
+
expect(navItem).toHaveAttribute('href', '#');
|
|
56
|
+
expect(navItem).toHaveTextContent('Admin');
|
|
57
|
+
});
|
|
58
|
+
it('should meet a11y standards', async () => {
|
|
59
|
+
const _render2 = render(_SideNavBarItem2 || (_SideNavBarItem2 = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
60
|
+
icon: /*#__PURE__*/React.createElement(IconAdminLine, null),
|
|
61
|
+
label: "Dashboard",
|
|
62
|
+
href: "#"
|
|
63
|
+
}))),
|
|
64
|
+
container = _render2.container;
|
|
65
|
+
const axeCheck = await runAxeCheck(container);
|
|
66
|
+
expect(axeCheck).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var _SideNavBarItem, _SideNavBarItem2, _SideNavBarItem3, _SideNavBarItem4, _SideNavBarItem5, _SideNavBarItem6, _SideNavBarItem7, _SideNavBarItem8;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
28
|
+
import userEvent from '@testing-library/user-event';
|
|
29
|
+
import { vi } from 'vitest';
|
|
30
|
+
import '@testing-library/jest-dom';
|
|
31
|
+
import { Badge } from '@instructure/ui-badge';
|
|
32
|
+
import { IconAdminLine, IconDashboardLine } from '@instructure/ui-icons';
|
|
33
|
+
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
34
|
+
import { SideNavBar, SideNavBarItem } from '../index';
|
|
35
|
+
describe('<SideNavBar />', () => {
|
|
36
|
+
let consoleErrorMock;
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
// Mocking console to prevent test output pollution
|
|
39
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
40
|
+
});
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
consoleErrorMock.mockRestore();
|
|
43
|
+
});
|
|
44
|
+
it('should render', async () => {
|
|
45
|
+
const _render = render( /*#__PURE__*/React.createElement(SideNavBar, {
|
|
46
|
+
label: "Main navigation",
|
|
47
|
+
toggleLabel: {
|
|
48
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
49
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
50
|
+
}
|
|
51
|
+
}, _SideNavBarItem || (_SideNavBarItem = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
52
|
+
icon: /*#__PURE__*/React.createElement(IconDashboardLine, null),
|
|
53
|
+
label: "Dashboard",
|
|
54
|
+
href: "#"
|
|
55
|
+
})))),
|
|
56
|
+
container = _render.container;
|
|
57
|
+
const nav = screen.getByRole('navigation');
|
|
58
|
+
const icons = container.querySelectorAll('svg');
|
|
59
|
+
expect(icons.length).toBe(2);
|
|
60
|
+
expect(icons[0]).toHaveAttribute('name', 'IconDashboard');
|
|
61
|
+
expect(icons[1]).toHaveAttribute('name', 'IconMoveStart');
|
|
62
|
+
expect(nav).toBeInTheDocument();
|
|
63
|
+
expect(nav.tagName).toBe('NAV');
|
|
64
|
+
expect(nav).toHaveAttribute('aria-label', 'Main navigation');
|
|
65
|
+
expect(nav).toHaveTextContent('Minimize SideNavBar');
|
|
66
|
+
});
|
|
67
|
+
it('should render a single semantic nav element', async () => {
|
|
68
|
+
render( /*#__PURE__*/React.createElement(SideNavBar, {
|
|
69
|
+
label: "Main navigation",
|
|
70
|
+
toggleLabel: {
|
|
71
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
72
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
73
|
+
}
|
|
74
|
+
}, _SideNavBarItem2 || (_SideNavBarItem2 = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
75
|
+
icon: /*#__PURE__*/React.createElement(IconDashboardLine, null),
|
|
76
|
+
label: "Dashboard",
|
|
77
|
+
href: "#"
|
|
78
|
+
}))));
|
|
79
|
+
const nav = screen.getByRole('navigation');
|
|
80
|
+
const navElements = screen.getAllByRole('listitem');
|
|
81
|
+
expect(nav).toBeInTheDocument();
|
|
82
|
+
expect(nav.tagName).toBe('NAV');
|
|
83
|
+
expect(navElements.length).toBe(1);
|
|
84
|
+
expect(navElements[0]).toHaveTextContent('Dashboard');
|
|
85
|
+
});
|
|
86
|
+
it('should render a semantic list for the nav content', async () => {
|
|
87
|
+
render( /*#__PURE__*/React.createElement(SideNavBar, {
|
|
88
|
+
label: "Main navigation",
|
|
89
|
+
toggleLabel: {
|
|
90
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
91
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
92
|
+
}
|
|
93
|
+
}, _SideNavBarItem3 || (_SideNavBarItem3 = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
94
|
+
icon: /*#__PURE__*/React.createElement(IconDashboardLine, null),
|
|
95
|
+
label: "Dashboard",
|
|
96
|
+
href: "#"
|
|
97
|
+
})), _SideNavBarItem4 || (_SideNavBarItem4 = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
98
|
+
icon: /*#__PURE__*/React.createElement(Badge, {
|
|
99
|
+
count: 99
|
|
100
|
+
}, /*#__PURE__*/React.createElement(IconAdminLine, null)),
|
|
101
|
+
label: "Inbox",
|
|
102
|
+
href: "#"
|
|
103
|
+
}))));
|
|
104
|
+
const list = screen.getAllByRole('list');
|
|
105
|
+
const navElements = screen.getAllByRole('listitem');
|
|
106
|
+
expect(list[0].tagName).toBe('UL');
|
|
107
|
+
expect(list.length).toBe(1);
|
|
108
|
+
expect(navElements.length).toBe(2);
|
|
109
|
+
});
|
|
110
|
+
it('should switch aria-expanded when the Toggle SideNavBar button is clicked', async () => {
|
|
111
|
+
render( /*#__PURE__*/React.createElement(SideNavBar, {
|
|
112
|
+
label: "Main navigation",
|
|
113
|
+
toggleLabel: {
|
|
114
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
115
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
116
|
+
}
|
|
117
|
+
}, _SideNavBarItem5 || (_SideNavBarItem5 = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
118
|
+
icon: /*#__PURE__*/React.createElement(IconDashboardLine, null),
|
|
119
|
+
label: "Dashboard",
|
|
120
|
+
href: "#"
|
|
121
|
+
})), _SideNavBarItem6 || (_SideNavBarItem6 = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
122
|
+
icon: /*#__PURE__*/React.createElement(Badge, {
|
|
123
|
+
count: 99
|
|
124
|
+
}, /*#__PURE__*/React.createElement(IconAdminLine, null)),
|
|
125
|
+
label: "Inbox",
|
|
126
|
+
href: "#"
|
|
127
|
+
}))));
|
|
128
|
+
const nav = screen.getByRole('navigation');
|
|
129
|
+
const toggleBtn = screen.getByRole('button');
|
|
130
|
+
expect(nav).toHaveTextContent('Minimize SideNavBar');
|
|
131
|
+
expect(toggleBtn).toHaveAttribute('aria-expanded', 'true');
|
|
132
|
+
userEvent.click(toggleBtn);
|
|
133
|
+
await waitFor(() => {
|
|
134
|
+
const updatedToggleBtn = screen.getByRole('button');
|
|
135
|
+
const updatedNav = screen.getByRole('navigation');
|
|
136
|
+
expect(updatedNav).toHaveTextContent('Expand SideNavBar');
|
|
137
|
+
expect(updatedToggleBtn).toHaveAttribute('aria-expanded', 'false');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
it('should meet a11y standards', async () => {
|
|
141
|
+
const _render2 = render( /*#__PURE__*/React.createElement(SideNavBar, {
|
|
142
|
+
label: "Main navigation",
|
|
143
|
+
toggleLabel: {
|
|
144
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
145
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
146
|
+
}
|
|
147
|
+
}, _SideNavBarItem7 || (_SideNavBarItem7 = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
148
|
+
icon: /*#__PURE__*/React.createElement(IconDashboardLine, null),
|
|
149
|
+
label: "Dashboard",
|
|
150
|
+
href: "#"
|
|
151
|
+
})), _SideNavBarItem8 || (_SideNavBarItem8 = /*#__PURE__*/React.createElement(SideNavBarItem, {
|
|
152
|
+
icon: /*#__PURE__*/React.createElement(Badge, {
|
|
153
|
+
count: 99
|
|
154
|
+
}, /*#__PURE__*/React.createElement(IconAdminLine, null)),
|
|
155
|
+
label: "Inbox",
|
|
156
|
+
href: "#"
|
|
157
|
+
})))),
|
|
158
|
+
container = _render2.container;
|
|
159
|
+
const axeCheck = await runAxeCheck(container);
|
|
160
|
+
expect(axeCheck).toBe(true);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
9
|
+
var _IconAdminLine = require("@instructure/ui-icons/lib/IconAdminLine.js");
|
|
10
|
+
var _index = require("../index");
|
|
11
|
+
var _SideNavBarItem, _SideNavBarItem2;
|
|
12
|
+
/*
|
|
13
|
+
* The MIT License (MIT)
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
* copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
* SOFTWARE.
|
|
34
|
+
*/
|
|
35
|
+
describe('<SideNavBarItem />', () => {
|
|
36
|
+
let consoleErrorMock;
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
// Mocking console to prevent test output pollution
|
|
39
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
40
|
+
});
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
consoleErrorMock.mockRestore();
|
|
43
|
+
});
|
|
44
|
+
it('should render', async () => {
|
|
45
|
+
const _render = (0, _react2.render)(_SideNavBarItem || (_SideNavBarItem = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
46
|
+
icon: /*#__PURE__*/_react.default.createElement(_IconAdminLine.IconAdminLine, null),
|
|
47
|
+
label: "Admin",
|
|
48
|
+
href: "#"
|
|
49
|
+
}))),
|
|
50
|
+
container = _render.container;
|
|
51
|
+
const navItem = _react2.screen.getByRole('link');
|
|
52
|
+
const icon = container.querySelector('svg');
|
|
53
|
+
expect(icon).toBeInTheDocument();
|
|
54
|
+
expect(icon).toHaveAttribute('name', 'IconAdmin');
|
|
55
|
+
expect(navItem).toBeInTheDocument();
|
|
56
|
+
expect(navItem.tagName).toBe('A');
|
|
57
|
+
expect(navItem).toHaveAttribute('href', '#');
|
|
58
|
+
expect(navItem).toHaveTextContent('Admin');
|
|
59
|
+
});
|
|
60
|
+
it('should meet a11y standards', async () => {
|
|
61
|
+
const _render2 = (0, _react2.render)(_SideNavBarItem2 || (_SideNavBarItem2 = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
62
|
+
icon: /*#__PURE__*/_react.default.createElement(_IconAdminLine.IconAdminLine, null),
|
|
63
|
+
label: "Dashboard",
|
|
64
|
+
href: "#"
|
|
65
|
+
}))),
|
|
66
|
+
container = _render2.container;
|
|
67
|
+
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
68
|
+
expect(axeCheck).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
7
|
+
var _vitest = require("vitest");
|
|
8
|
+
require("@testing-library/jest-dom");
|
|
9
|
+
var _Badge = require("@instructure/ui-badge/lib/Badge");
|
|
10
|
+
var _IconAdminLine = require("@instructure/ui-icons/lib/IconAdminLine.js");
|
|
11
|
+
var _IconDashboardLine = require("@instructure/ui-icons/lib/IconDashboardLine.js");
|
|
12
|
+
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
13
|
+
var _index = require("../index");
|
|
14
|
+
var _SideNavBarItem, _SideNavBarItem2, _SideNavBarItem3, _SideNavBarItem4, _SideNavBarItem5, _SideNavBarItem6, _SideNavBarItem7, _SideNavBarItem8;
|
|
15
|
+
/*
|
|
16
|
+
* The MIT License (MIT)
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
19
|
+
*
|
|
20
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
21
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
22
|
+
* in the Software without restriction, including without limitation the rights
|
|
23
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
24
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
25
|
+
* furnished to do so, subject to the following conditions:
|
|
26
|
+
*
|
|
27
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
28
|
+
* copies or substantial portions of the Software.
|
|
29
|
+
*
|
|
30
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
31
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
32
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
33
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
34
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
35
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
36
|
+
* SOFTWARE.
|
|
37
|
+
*/
|
|
38
|
+
describe('<SideNavBar />', () => {
|
|
39
|
+
let consoleErrorMock;
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
// Mocking console to prevent test output pollution
|
|
42
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
43
|
+
});
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
consoleErrorMock.mockRestore();
|
|
46
|
+
});
|
|
47
|
+
it('should render', async () => {
|
|
48
|
+
const _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.SideNavBar, {
|
|
49
|
+
label: "Main navigation",
|
|
50
|
+
toggleLabel: {
|
|
51
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
52
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
53
|
+
}
|
|
54
|
+
}, _SideNavBarItem || (_SideNavBarItem = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
55
|
+
icon: /*#__PURE__*/_react.default.createElement(_IconDashboardLine.IconDashboardLine, null),
|
|
56
|
+
label: "Dashboard",
|
|
57
|
+
href: "#"
|
|
58
|
+
})))),
|
|
59
|
+
container = _render.container;
|
|
60
|
+
const nav = _react2.screen.getByRole('navigation');
|
|
61
|
+
const icons = container.querySelectorAll('svg');
|
|
62
|
+
expect(icons.length).toBe(2);
|
|
63
|
+
expect(icons[0]).toHaveAttribute('name', 'IconDashboard');
|
|
64
|
+
expect(icons[1]).toHaveAttribute('name', 'IconMoveStart');
|
|
65
|
+
expect(nav).toBeInTheDocument();
|
|
66
|
+
expect(nav.tagName).toBe('NAV');
|
|
67
|
+
expect(nav).toHaveAttribute('aria-label', 'Main navigation');
|
|
68
|
+
expect(nav).toHaveTextContent('Minimize SideNavBar');
|
|
69
|
+
});
|
|
70
|
+
it('should render a single semantic nav element', async () => {
|
|
71
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.SideNavBar, {
|
|
72
|
+
label: "Main navigation",
|
|
73
|
+
toggleLabel: {
|
|
74
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
75
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
76
|
+
}
|
|
77
|
+
}, _SideNavBarItem2 || (_SideNavBarItem2 = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
78
|
+
icon: /*#__PURE__*/_react.default.createElement(_IconDashboardLine.IconDashboardLine, null),
|
|
79
|
+
label: "Dashboard",
|
|
80
|
+
href: "#"
|
|
81
|
+
}))));
|
|
82
|
+
const nav = _react2.screen.getByRole('navigation');
|
|
83
|
+
const navElements = _react2.screen.getAllByRole('listitem');
|
|
84
|
+
expect(nav).toBeInTheDocument();
|
|
85
|
+
expect(nav.tagName).toBe('NAV');
|
|
86
|
+
expect(navElements.length).toBe(1);
|
|
87
|
+
expect(navElements[0]).toHaveTextContent('Dashboard');
|
|
88
|
+
});
|
|
89
|
+
it('should render a semantic list for the nav content', async () => {
|
|
90
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.SideNavBar, {
|
|
91
|
+
label: "Main navigation",
|
|
92
|
+
toggleLabel: {
|
|
93
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
94
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
95
|
+
}
|
|
96
|
+
}, _SideNavBarItem3 || (_SideNavBarItem3 = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
97
|
+
icon: /*#__PURE__*/_react.default.createElement(_IconDashboardLine.IconDashboardLine, null),
|
|
98
|
+
label: "Dashboard",
|
|
99
|
+
href: "#"
|
|
100
|
+
})), _SideNavBarItem4 || (_SideNavBarItem4 = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
101
|
+
icon: /*#__PURE__*/_react.default.createElement(_Badge.Badge, {
|
|
102
|
+
count: 99
|
|
103
|
+
}, /*#__PURE__*/_react.default.createElement(_IconAdminLine.IconAdminLine, null)),
|
|
104
|
+
label: "Inbox",
|
|
105
|
+
href: "#"
|
|
106
|
+
}))));
|
|
107
|
+
const list = _react2.screen.getAllByRole('list');
|
|
108
|
+
const navElements = _react2.screen.getAllByRole('listitem');
|
|
109
|
+
expect(list[0].tagName).toBe('UL');
|
|
110
|
+
expect(list.length).toBe(1);
|
|
111
|
+
expect(navElements.length).toBe(2);
|
|
112
|
+
});
|
|
113
|
+
it('should switch aria-expanded when the Toggle SideNavBar button is clicked', async () => {
|
|
114
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.SideNavBar, {
|
|
115
|
+
label: "Main navigation",
|
|
116
|
+
toggleLabel: {
|
|
117
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
118
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
119
|
+
}
|
|
120
|
+
}, _SideNavBarItem5 || (_SideNavBarItem5 = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
121
|
+
icon: /*#__PURE__*/_react.default.createElement(_IconDashboardLine.IconDashboardLine, null),
|
|
122
|
+
label: "Dashboard",
|
|
123
|
+
href: "#"
|
|
124
|
+
})), _SideNavBarItem6 || (_SideNavBarItem6 = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
125
|
+
icon: /*#__PURE__*/_react.default.createElement(_Badge.Badge, {
|
|
126
|
+
count: 99
|
|
127
|
+
}, /*#__PURE__*/_react.default.createElement(_IconAdminLine.IconAdminLine, null)),
|
|
128
|
+
label: "Inbox",
|
|
129
|
+
href: "#"
|
|
130
|
+
}))));
|
|
131
|
+
const nav = _react2.screen.getByRole('navigation');
|
|
132
|
+
const toggleBtn = _react2.screen.getByRole('button');
|
|
133
|
+
expect(nav).toHaveTextContent('Minimize SideNavBar');
|
|
134
|
+
expect(toggleBtn).toHaveAttribute('aria-expanded', 'true');
|
|
135
|
+
_userEvent.default.click(toggleBtn);
|
|
136
|
+
await (0, _react2.waitFor)(() => {
|
|
137
|
+
const updatedToggleBtn = _react2.screen.getByRole('button');
|
|
138
|
+
const updatedNav = _react2.screen.getByRole('navigation');
|
|
139
|
+
expect(updatedNav).toHaveTextContent('Expand SideNavBar');
|
|
140
|
+
expect(updatedToggleBtn).toHaveAttribute('aria-expanded', 'false');
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
it('should meet a11y standards', async () => {
|
|
144
|
+
const _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.SideNavBar, {
|
|
145
|
+
label: "Main navigation",
|
|
146
|
+
toggleLabel: {
|
|
147
|
+
expandedLabel: 'Minimize SideNavBar',
|
|
148
|
+
minimizedLabel: 'Expand SideNavBar'
|
|
149
|
+
}
|
|
150
|
+
}, _SideNavBarItem7 || (_SideNavBarItem7 = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
151
|
+
icon: /*#__PURE__*/_react.default.createElement(_IconDashboardLine.IconDashboardLine, null),
|
|
152
|
+
label: "Dashboard",
|
|
153
|
+
href: "#"
|
|
154
|
+
})), _SideNavBarItem8 || (_SideNavBarItem8 = /*#__PURE__*/_react.default.createElement(_index.SideNavBarItem, {
|
|
155
|
+
icon: /*#__PURE__*/_react.default.createElement(_Badge.Badge, {
|
|
156
|
+
count: 99
|
|
157
|
+
}, /*#__PURE__*/_react.default.createElement(_IconAdminLine.IconAdminLine, null)),
|
|
158
|
+
label: "Inbox",
|
|
159
|
+
href: "#"
|
|
160
|
+
})))),
|
|
161
|
+
container = _render2.container;
|
|
162
|
+
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
163
|
+
expect(axeCheck).toBe(true);
|
|
164
|
+
});
|
|
165
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-side-nav-bar",
|
|
3
|
-
"version": "9.3.1-snapshot-
|
|
3
|
+
"version": "9.3.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,25 +23,29 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-
|
|
27
|
-
"@instructure/ui-
|
|
28
|
-
"@instructure/ui-
|
|
29
|
-
"@instructure/ui-test-utils": "9.3.1-snapshot-
|
|
30
|
-
"@instructure/ui-themes": "9.3.1-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "9.3.1-snapshot-2",
|
|
27
|
+
"@instructure/ui-babel-preset": "9.3.1-snapshot-2",
|
|
28
|
+
"@instructure/ui-color-utils": "9.3.1-snapshot-2",
|
|
29
|
+
"@instructure/ui-test-utils": "9.3.1-snapshot-2",
|
|
30
|
+
"@instructure/ui-themes": "9.3.1-snapshot-2",
|
|
31
|
+
"@testing-library/jest-dom": "^6.4.6",
|
|
32
|
+
"@testing-library/react": "^15.0.7",
|
|
33
|
+
"@testing-library/user-event": "^14.5.2",
|
|
34
|
+
"vitest": "^1.6.0"
|
|
31
35
|
},
|
|
32
36
|
"dependencies": {
|
|
33
37
|
"@babel/runtime": "^7.24.5",
|
|
34
|
-
"@instructure/debounce": "9.3.1-snapshot-
|
|
35
|
-
"@instructure/emotion": "9.3.1-snapshot-
|
|
36
|
-
"@instructure/shared-types": "9.3.1-snapshot-
|
|
37
|
-
"@instructure/ui-a11y-content": "9.3.1-snapshot-
|
|
38
|
-
"@instructure/ui-a11y-utils": "9.3.1-snapshot-
|
|
39
|
-
"@instructure/ui-badge": "9.3.1-snapshot-
|
|
40
|
-
"@instructure/ui-icons": "9.3.1-snapshot-
|
|
41
|
-
"@instructure/ui-prop-types": "9.3.1-snapshot-
|
|
42
|
-
"@instructure/ui-react-utils": "9.3.1-snapshot-
|
|
43
|
-
"@instructure/ui-testable": "9.3.1-snapshot-
|
|
44
|
-
"@instructure/ui-tooltip": "9.3.1-snapshot-
|
|
38
|
+
"@instructure/debounce": "9.3.1-snapshot-2",
|
|
39
|
+
"@instructure/emotion": "9.3.1-snapshot-2",
|
|
40
|
+
"@instructure/shared-types": "9.3.1-snapshot-2",
|
|
41
|
+
"@instructure/ui-a11y-content": "9.3.1-snapshot-2",
|
|
42
|
+
"@instructure/ui-a11y-utils": "9.3.1-snapshot-2",
|
|
43
|
+
"@instructure/ui-badge": "9.3.1-snapshot-2",
|
|
44
|
+
"@instructure/ui-icons": "9.3.1-snapshot-2",
|
|
45
|
+
"@instructure/ui-prop-types": "9.3.1-snapshot-2",
|
|
46
|
+
"@instructure/ui-react-utils": "9.3.1-snapshot-2",
|
|
47
|
+
"@instructure/ui-testable": "9.3.1-snapshot-2",
|
|
48
|
+
"@instructure/ui-tooltip": "9.3.1-snapshot-2",
|
|
45
49
|
"prop-types": "^15.8.1"
|
|
46
50
|
},
|
|
47
51
|
"peerDependencies": {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import { render, screen } from '@testing-library/react'
|
|
27
|
+
import { vi } from 'vitest'
|
|
28
|
+
import '@testing-library/jest-dom'
|
|
29
|
+
|
|
30
|
+
import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
31
|
+
import { IconAdminLine } from '@instructure/ui-icons'
|
|
32
|
+
import { SideNavBarItem } from '../index'
|
|
33
|
+
|
|
34
|
+
describe('<SideNavBarItem />', () => {
|
|
35
|
+
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
// Mocking console to prevent test output pollution
|
|
39
|
+
consoleErrorMock = vi
|
|
40
|
+
.spyOn(console, 'error')
|
|
41
|
+
.mockImplementation(() => {}) as any
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
consoleErrorMock.mockRestore()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should render', async () => {
|
|
49
|
+
const { container } = render(
|
|
50
|
+
<SideNavBarItem icon={<IconAdminLine />} label="Admin" href="#" />
|
|
51
|
+
)
|
|
52
|
+
const navItem = screen.getByRole('link')
|
|
53
|
+
const icon = container.querySelector('svg')
|
|
54
|
+
|
|
55
|
+
expect(icon).toBeInTheDocument()
|
|
56
|
+
expect(icon).toHaveAttribute('name', 'IconAdmin')
|
|
57
|
+
|
|
58
|
+
expect(navItem).toBeInTheDocument()
|
|
59
|
+
expect(navItem.tagName).toBe('A')
|
|
60
|
+
expect(navItem).toHaveAttribute('href', '#')
|
|
61
|
+
expect(navItem).toHaveTextContent('Admin')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should meet a11y standards', async () => {
|
|
65
|
+
const { container } = render(
|
|
66
|
+
<SideNavBarItem icon={<IconAdminLine />} label="Dashboard" href="#" />
|
|
67
|
+
)
|
|
68
|
+
const axeCheck = await runAxeCheck(container)
|
|
69
|
+
|
|
70
|
+
expect(axeCheck).toBe(true)
|
|
71
|
+
})
|
|
72
|
+
})
|