@instructure/ui-navigation 10.19.2-snapshot-3 → 10.19.2-snapshot-4

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.
@@ -1,130 +0,0 @@
1
- var _Item, _Item2, _Item3, _ScreenReaderContent;
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 { render, screen, waitFor } from '@testing-library/react';
27
- import { vi } from 'vitest';
28
- import userEvent from '@testing-library/user-event';
29
- import '@testing-library/jest-dom';
30
- import { runAxeCheck } from '@instructure/ui-axe-check';
31
- import { ScreenReaderContent } from '@instructure/ui-a11y-content';
32
- import { Item } from '../index';
33
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
34
- const icon = _jsxs("svg", {
35
- height: "24",
36
- width: "24",
37
- children: [_jsx("title", {
38
- children: "Some icon"
39
- }), _jsx("circle", {
40
- cx: "50",
41
- cy: "50",
42
- r: "40"
43
- })]
44
- });
45
- describe('<AppNav.Item />', () => {
46
- let consoleWarningMock;
47
- let consoleErrorMock;
48
- beforeEach(() => {
49
- // Mocking console to prevent test output pollution and expect for messages
50
- consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
51
- consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
52
- });
53
- afterEach(() => {
54
- consoleWarningMock.mockRestore();
55
- consoleErrorMock.mockRestore();
56
- });
57
- it('should render label text', async () => {
58
- render(_Item || (_Item = _jsx(Item, {
59
- renderLabel: "Some label",
60
- href: "#"
61
- })));
62
- const item = screen.getByRole('link');
63
- expect(item).toHaveTextContent('Some label');
64
- });
65
- it('should render an icon/image/etc.', async () => {
66
- const _render = render(_Item2 || (_Item2 = _jsx(Item, {
67
- renderIcon: icon,
68
- renderLabel: _jsx(ScreenReaderContent, {
69
- children: "Some label"
70
- }),
71
- href: "#"
72
- }))),
73
- container = _render.container;
74
- const iconTitle = screen.getByTitle('Some icon');
75
- const iconSvg = container.querySelector('svg');
76
- const item = screen.getByRole('link');
77
- expect(iconTitle).toBeInTheDocument();
78
- expect(iconSvg).toBeInTheDocument();
79
- expect(iconSvg).toHaveTextContent('Some icon');
80
- expect(item).toHaveTextContent('Some label');
81
- });
82
- it('should render content after the label text to accommodate badges, etc.', async () => {
83
- render(_Item3 || (_Item3 = _jsx(Item, {
84
- renderLabel: "Some label",
85
- href: "#",
86
- renderAfter: _jsx("strong", {
87
- children: "I am rendered after!"
88
- })
89
- })));
90
- const item = screen.getByRole('link');
91
- const after = screen.getByText('I am rendered after!');
92
- expect(item).toBeInTheDocument();
93
- expect(item).toHaveTextContent('Some label');
94
- expect(after).toBeInTheDocument();
95
- expect(after.tagName).toBe('STRONG');
96
- });
97
- it('should respond to an onClick event', async () => {
98
- const onClick = vi.fn();
99
- render(_jsx(Item, {
100
- renderLabel: "Some label",
101
- onClick: onClick
102
- }));
103
- const button = screen.getByRole('button');
104
- await userEvent.click(button);
105
- await waitFor(() => {
106
- expect(onClick).toHaveBeenCalledTimes(1);
107
- });
108
- });
109
- it('should output a console error if icon is used with non-screenreader label text', async () => {
110
- render(_jsx(Item, {
111
- renderIcon: icon,
112
- renderLabel: "Some label",
113
- onClick: () => 'clicked'
114
- }));
115
- const expectedErrorMessage = 'Warning: [AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.';
116
- expect(consoleErrorMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
117
- });
118
- it('should meet a11y standards', async () => {
119
- const _render2 = render(_jsx(Item, {
120
- renderIcon: icon,
121
- renderLabel: _ScreenReaderContent || (_ScreenReaderContent = _jsx(ScreenReaderContent, {
122
- children: "Some label"
123
- })),
124
- onClick: () => 'clicked'
125
- })),
126
- container = _render2.container;
127
- const axeCheck = await runAxeCheck(container);
128
- expect(axeCheck).toBe(true);
129
- });
130
- });
@@ -1,161 +0,0 @@
1
- var _AppNav, _AppNav$Item, _AppNav2, _AppNav3, _AppNav$Item2, _AppNav$Item3, _AppNav$Item4, _AppNav$Item5;
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 { render, screen } from '@testing-library/react';
27
- import { vi } from 'vitest';
28
- import '@testing-library/jest-dom';
29
-
30
- // eslint-disable-next-line no-restricted-imports
31
- import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests';
32
- import { runAxeCheck } from '@instructure/ui-axe-check';
33
- import { AppNav } from '../index';
34
- import AppNavExamples from '../__examples__/AppNav.examples';
35
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
36
- describe('<AppNav />', () => {
37
- let consoleErrorMock;
38
- beforeEach(() => {
39
- // Mocking console to prevent test output pollution
40
- consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
41
- });
42
- afterEach(() => {
43
- consoleErrorMock.mockRestore();
44
- });
45
- describe('for a11y', () => {
46
- it('should render a nav element with an aria-label', async () => {
47
- const _render = render(_AppNav || (_AppNav = _jsxs(AppNav, {
48
- screenReaderLabel: "Screen reader label",
49
- visibleItemsCount: 2,
50
- children: [_jsx(AppNav.Item, {
51
- renderLabel: "Some label",
52
- href: "http://instructure.design"
53
- }), _jsx(AppNav.Item, {
54
- renderLabel: "Some other label",
55
- href: "http://instructure.design"
56
- })]
57
- }))),
58
- container = _render.container;
59
- const appNavList = container.querySelector('ul[class*="-appNav__list"]');
60
- expect(appNavList).toBeInTheDocument();
61
- expect(appNavList.tagName).toBe('UL');
62
- expect(appNavList).toHaveAttribute('aria-label', 'Screen reader label');
63
- });
64
- it('should render a semantic list of items', async () => {
65
- render(_jsxs(AppNav, {
66
- screenReaderLabel: "App navigation",
67
- visibleItemsCount: 2,
68
- children: [_AppNav$Item || (_AppNav$Item = _jsx(AppNav.Item, {
69
- renderLabel: "Some first label",
70
- href: "http://instructure.design"
71
- })), _jsx(AppNav.Item, {
72
- renderLabel: "Some second label",
73
- onClick: () => 'clicked'
74
- })]
75
- }));
76
- const list = screen.getAllByRole('list');
77
- const items = screen.getAllByRole('listitem');
78
- const link = screen.getAllByRole('link');
79
- const button = screen.getAllByRole('button');
80
- expect(list.length).toBe(1);
81
- expect(items.length).toBe(2);
82
- expect(link.length).toBe(1);
83
- expect(button.length).toBe(1);
84
- });
85
- it('should render with a single item', async () => {
86
- render(_AppNav2 || (_AppNav2 = _jsx(AppNav, {
87
- screenReaderLabel: "App navigation",
88
- visibleItemsCount: 1,
89
- children: _jsx(AppNav.Item, {
90
- renderLabel: "Some label",
91
- href: "http://instructure.design"
92
- })
93
- })));
94
- const list = screen.getAllByRole('list');
95
- const items = screen.getAllByRole('listitem');
96
- const link = screen.getAllByRole('link');
97
- expect(list.length).toBe(1);
98
- expect(items.length).toBe(1);
99
- expect(link.length).toBe(1);
100
- });
101
- });
102
- describe('with rendered content', () => {
103
- it('should render content after the navigation', async () => {
104
- render(_AppNav3 || (_AppNav3 = _jsxs(AppNav, {
105
- screenReaderLabel: "App navigation",
106
- renderAfterItems: _jsx("button", {
107
- type: "button",
108
- children: "I am rendered after!"
109
- }),
110
- visibleItemsCount: 2,
111
- children: [_jsx(AppNav.Item, {
112
- renderLabel: "Some label",
113
- href: "http://instructure.design"
114
- }), _jsx(AppNav.Item, {
115
- renderLabel: "Some other label",
116
- href: "http://instructure.design"
117
- })]
118
- })));
119
- const button = screen.getByRole('button');
120
- expect(button).toHaveTextContent('I am rendered after!');
121
- });
122
- });
123
- describe('with item truncation', () => {
124
- it('should pass a custom label to the menu trigger', async () => {
125
- render(_jsxs(AppNav, {
126
- screenReaderLabel: "App navigation",
127
- visibleItemsCount: 2,
128
- renderTruncateLabel: function () {
129
- return 'I am sooo custom!';
130
- },
131
- children: [_AppNav$Item2 || (_AppNav$Item2 = _jsx(AppNav.Item, {
132
- renderLabel: "Label",
133
- href: "http://instructure.design"
134
- })), _AppNav$Item3 || (_AppNav$Item3 = _jsx(AppNav.Item, {
135
- renderLabel: "Label",
136
- href: "http://instructure.design"
137
- })), _AppNav$Item4 || (_AppNav$Item4 = _jsx(AppNav.Item, {
138
- renderLabel: "Label",
139
- href: "http://instructure.design"
140
- })), _AppNav$Item5 || (_AppNav$Item5 = _jsx(AppNav.Item, {
141
- renderLabel: "Label",
142
- href: "http://instructure.design"
143
- }))]
144
- }));
145
- const items = screen.getAllByRole('listitem');
146
- expect(items.length).toBe(3);
147
- expect(items[2]).toHaveTextContent('I am sooo custom!');
148
- });
149
- });
150
- describe('with generated examples', () => {
151
- const generatedComponents = generateA11yTests(AppNav, AppNavExamples);
152
- for (const component of generatedComponents) {
153
- it(component.description, async () => {
154
- const _render2 = render(component.content),
155
- container = _render2.container;
156
- const axeCheck = await runAxeCheck(container);
157
- expect(axeCheck).toBe(true);
158
- });
159
- }
160
- });
161
- });
@@ -1,132 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("@testing-library/react");
5
- var _vitest = require("vitest");
6
- var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
7
- require("@testing-library/jest-dom");
8
- var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
9
- var _ScreenReaderContent2 = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
10
- var _index = require("../index");
11
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
- var _Item, _Item2, _Item3, _ScreenReaderContent;
13
- /*
14
- * The MIT License (MIT)
15
- *
16
- * Copyright (c) 2015 - present Instructure, Inc.
17
- *
18
- * Permission is hereby granted, free of charge, to any person obtaining a copy
19
- * of this software and associated documentation files (the "Software"), to deal
20
- * in the Software without restriction, including without limitation the rights
21
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
- * copies of the Software, and to permit persons to whom the Software is
23
- * furnished to do so, subject to the following conditions:
24
- *
25
- * The above copyright notice and this permission notice shall be included in all
26
- * copies or substantial portions of the Software.
27
- *
28
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
- * SOFTWARE.
35
- */
36
- const icon = (0, _jsxRuntime.jsxs)("svg", {
37
- height: "24",
38
- width: "24",
39
- children: [(0, _jsxRuntime.jsx)("title", {
40
- children: "Some icon"
41
- }), (0, _jsxRuntime.jsx)("circle", {
42
- cx: "50",
43
- cy: "50",
44
- r: "40"
45
- })]
46
- });
47
- describe('<AppNav.Item />', () => {
48
- let consoleWarningMock;
49
- let consoleErrorMock;
50
- beforeEach(() => {
51
- // Mocking console to prevent test output pollution and expect for messages
52
- consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
53
- consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
54
- });
55
- afterEach(() => {
56
- consoleWarningMock.mockRestore();
57
- consoleErrorMock.mockRestore();
58
- });
59
- it('should render label text', async () => {
60
- (0, _react.render)(_Item || (_Item = (0, _jsxRuntime.jsx)(_index.Item, {
61
- renderLabel: "Some label",
62
- href: "#"
63
- })));
64
- const item = _react.screen.getByRole('link');
65
- expect(item).toHaveTextContent('Some label');
66
- });
67
- it('should render an icon/image/etc.', async () => {
68
- const _render = (0, _react.render)(_Item2 || (_Item2 = (0, _jsxRuntime.jsx)(_index.Item, {
69
- renderIcon: icon,
70
- renderLabel: (0, _jsxRuntime.jsx)(_ScreenReaderContent2.ScreenReaderContent, {
71
- children: "Some label"
72
- }),
73
- href: "#"
74
- }))),
75
- container = _render.container;
76
- const iconTitle = _react.screen.getByTitle('Some icon');
77
- const iconSvg = container.querySelector('svg');
78
- const item = _react.screen.getByRole('link');
79
- expect(iconTitle).toBeInTheDocument();
80
- expect(iconSvg).toBeInTheDocument();
81
- expect(iconSvg).toHaveTextContent('Some icon');
82
- expect(item).toHaveTextContent('Some label');
83
- });
84
- it('should render content after the label text to accommodate badges, etc.', async () => {
85
- (0, _react.render)(_Item3 || (_Item3 = (0, _jsxRuntime.jsx)(_index.Item, {
86
- renderLabel: "Some label",
87
- href: "#",
88
- renderAfter: (0, _jsxRuntime.jsx)("strong", {
89
- children: "I am rendered after!"
90
- })
91
- })));
92
- const item = _react.screen.getByRole('link');
93
- const after = _react.screen.getByText('I am rendered after!');
94
- expect(item).toBeInTheDocument();
95
- expect(item).toHaveTextContent('Some label');
96
- expect(after).toBeInTheDocument();
97
- expect(after.tagName).toBe('STRONG');
98
- });
99
- it('should respond to an onClick event', async () => {
100
- const onClick = _vitest.vi.fn();
101
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Item, {
102
- renderLabel: "Some label",
103
- onClick: onClick
104
- }));
105
- const button = _react.screen.getByRole('button');
106
- await _userEvent.default.click(button);
107
- await (0, _react.waitFor)(() => {
108
- expect(onClick).toHaveBeenCalledTimes(1);
109
- });
110
- });
111
- it('should output a console error if icon is used with non-screenreader label text', async () => {
112
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Item, {
113
- renderIcon: icon,
114
- renderLabel: "Some label",
115
- onClick: () => 'clicked'
116
- }));
117
- const expectedErrorMessage = 'Warning: [AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.';
118
- expect(consoleErrorMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
119
- });
120
- it('should meet a11y standards', async () => {
121
- const _render2 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Item, {
122
- renderIcon: icon,
123
- renderLabel: _ScreenReaderContent || (_ScreenReaderContent = (0, _jsxRuntime.jsx)(_ScreenReaderContent2.ScreenReaderContent, {
124
- children: "Some label"
125
- })),
126
- onClick: () => 'clicked'
127
- })),
128
- container = _render2.container;
129
- const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
130
- expect(axeCheck).toBe(true);
131
- });
132
- });
@@ -1,162 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("@testing-library/react");
5
- var _vitest = require("vitest");
6
- require("@testing-library/jest-dom");
7
- var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yTests");
8
- var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
9
- var _index = require("../index");
10
- var _AppNav4 = _interopRequireDefault(require("../__examples__/AppNav.examples"));
11
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
- var _AppNav, _AppNav$Item, _AppNav2, _AppNav3, _AppNav$Item2, _AppNav$Item3, _AppNav$Item4, _AppNav$Item5;
13
- /*
14
- * The MIT License (MIT)
15
- *
16
- * Copyright (c) 2015 - present Instructure, Inc.
17
- *
18
- * Permission is hereby granted, free of charge, to any person obtaining a copy
19
- * of this software and associated documentation files (the "Software"), to deal
20
- * in the Software without restriction, including without limitation the rights
21
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
- * copies of the Software, and to permit persons to whom the Software is
23
- * furnished to do so, subject to the following conditions:
24
- *
25
- * The above copyright notice and this permission notice shall be included in all
26
- * copies or substantial portions of the Software.
27
- *
28
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
- * SOFTWARE.
35
- */
36
- // eslint-disable-next-line no-restricted-imports
37
- describe('<AppNav />', () => {
38
- let consoleErrorMock;
39
- beforeEach(() => {
40
- // Mocking console to prevent test output pollution
41
- consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
42
- });
43
- afterEach(() => {
44
- consoleErrorMock.mockRestore();
45
- });
46
- describe('for a11y', () => {
47
- it('should render a nav element with an aria-label', async () => {
48
- const _render = (0, _react.render)(_AppNav || (_AppNav = (0, _jsxRuntime.jsxs)(_index.AppNav, {
49
- screenReaderLabel: "Screen reader label",
50
- visibleItemsCount: 2,
51
- children: [(0, _jsxRuntime.jsx)(_index.AppNav.Item, {
52
- renderLabel: "Some label",
53
- href: "http://instructure.design"
54
- }), (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
55
- renderLabel: "Some other label",
56
- href: "http://instructure.design"
57
- })]
58
- }))),
59
- container = _render.container;
60
- const appNavList = container.querySelector('ul[class*="-appNav__list"]');
61
- expect(appNavList).toBeInTheDocument();
62
- expect(appNavList.tagName).toBe('UL');
63
- expect(appNavList).toHaveAttribute('aria-label', 'Screen reader label');
64
- });
65
- it('should render a semantic list of items', async () => {
66
- (0, _react.render)((0, _jsxRuntime.jsxs)(_index.AppNav, {
67
- screenReaderLabel: "App navigation",
68
- visibleItemsCount: 2,
69
- children: [_AppNav$Item || (_AppNav$Item = (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
70
- renderLabel: "Some first label",
71
- href: "http://instructure.design"
72
- })), (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
73
- renderLabel: "Some second label",
74
- onClick: () => 'clicked'
75
- })]
76
- }));
77
- const list = _react.screen.getAllByRole('list');
78
- const items = _react.screen.getAllByRole('listitem');
79
- const link = _react.screen.getAllByRole('link');
80
- const button = _react.screen.getAllByRole('button');
81
- expect(list.length).toBe(1);
82
- expect(items.length).toBe(2);
83
- expect(link.length).toBe(1);
84
- expect(button.length).toBe(1);
85
- });
86
- it('should render with a single item', async () => {
87
- (0, _react.render)(_AppNav2 || (_AppNav2 = (0, _jsxRuntime.jsx)(_index.AppNav, {
88
- screenReaderLabel: "App navigation",
89
- visibleItemsCount: 1,
90
- children: (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
91
- renderLabel: "Some label",
92
- href: "http://instructure.design"
93
- })
94
- })));
95
- const list = _react.screen.getAllByRole('list');
96
- const items = _react.screen.getAllByRole('listitem');
97
- const link = _react.screen.getAllByRole('link');
98
- expect(list.length).toBe(1);
99
- expect(items.length).toBe(1);
100
- expect(link.length).toBe(1);
101
- });
102
- });
103
- describe('with rendered content', () => {
104
- it('should render content after the navigation', async () => {
105
- (0, _react.render)(_AppNav3 || (_AppNav3 = (0, _jsxRuntime.jsxs)(_index.AppNav, {
106
- screenReaderLabel: "App navigation",
107
- renderAfterItems: (0, _jsxRuntime.jsx)("button", {
108
- type: "button",
109
- children: "I am rendered after!"
110
- }),
111
- visibleItemsCount: 2,
112
- children: [(0, _jsxRuntime.jsx)(_index.AppNav.Item, {
113
- renderLabel: "Some label",
114
- href: "http://instructure.design"
115
- }), (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
116
- renderLabel: "Some other label",
117
- href: "http://instructure.design"
118
- })]
119
- })));
120
- const button = _react.screen.getByRole('button');
121
- expect(button).toHaveTextContent('I am rendered after!');
122
- });
123
- });
124
- describe('with item truncation', () => {
125
- it('should pass a custom label to the menu trigger', async () => {
126
- (0, _react.render)((0, _jsxRuntime.jsxs)(_index.AppNav, {
127
- screenReaderLabel: "App navigation",
128
- visibleItemsCount: 2,
129
- renderTruncateLabel: function () {
130
- return 'I am sooo custom!';
131
- },
132
- children: [_AppNav$Item2 || (_AppNav$Item2 = (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
133
- renderLabel: "Label",
134
- href: "http://instructure.design"
135
- })), _AppNav$Item3 || (_AppNav$Item3 = (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
136
- renderLabel: "Label",
137
- href: "http://instructure.design"
138
- })), _AppNav$Item4 || (_AppNav$Item4 = (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
139
- renderLabel: "Label",
140
- href: "http://instructure.design"
141
- })), _AppNav$Item5 || (_AppNav$Item5 = (0, _jsxRuntime.jsx)(_index.AppNav.Item, {
142
- renderLabel: "Label",
143
- href: "http://instructure.design"
144
- }))]
145
- }));
146
- const items = _react.screen.getAllByRole('listitem');
147
- expect(items.length).toBe(3);
148
- expect(items[2]).toHaveTextContent('I am sooo custom!');
149
- });
150
- });
151
- describe('with generated examples', () => {
152
- const generatedComponents = (0, _generateA11yTests.generateA11yTests)(_index.AppNav, _AppNav4.default);
153
- for (const component of generatedComponents) {
154
- it(component.description, async () => {
155
- const _render2 = (0, _react.render)(component.content),
156
- container = _render2.container;
157
- const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
158
- expect(axeCheck).toBe(true);
159
- });
160
- }
161
- });
162
- });