@instructure/ui-drilldown 10.19.2-snapshot-2 → 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.
Files changed (28) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +21 -21
  3. package/tsconfig.build.tsbuildinfo +1 -1
  4. package/es/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.js +0 -696
  5. package/es/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.js +0 -708
  6. package/es/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.js +0 -353
  7. package/es/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.js +0 -61
  8. package/es/Drilldown/__new-tests__/Drilldown.test.js +0 -1021
  9. package/lib/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.js +0 -698
  10. package/lib/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.js +0 -710
  11. package/lib/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.js +0 -355
  12. package/lib/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.js +0 -62
  13. package/lib/Drilldown/__new-tests__/Drilldown.test.js +0 -1022
  14. package/src/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.tsx +0 -633
  15. package/src/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.tsx +0 -774
  16. package/src/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.tsx +0 -351
  17. package/src/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.tsx +0 -59
  18. package/src/Drilldown/__new-tests__/Drilldown.test.tsx +0 -1005
  19. package/types/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.d.ts +0 -2
  20. package/types/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.d.ts.map +0 -1
  21. package/types/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.d.ts +0 -2
  22. package/types/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.d.ts.map +0 -1
  23. package/types/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.d.ts +0 -2
  24. package/types/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.d.ts.map +0 -1
  25. package/types/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.d.ts +0 -2
  26. package/types/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.d.ts.map +0 -1
  27. package/types/Drilldown/__new-tests__/Drilldown.test.d.ts +0 -2
  28. package/types/Drilldown/__new-tests__/Drilldown.test.d.ts.map +0 -1
@@ -1,355 +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 _index = require("../../index");
9
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
- var _Drilldown, _Drilldown2, _Drilldown$Option, _Drilldown$Option2, _Drilldown3, _Drilldown$Option3, _Drilldown$Option4, _Drilldown$Option5, _Drilldown4, _Drilldown5, _Drilldown$Option6, _Drilldown$Option7, _Drilldown6, _Drilldown7, _Drilldown8, _Drilldown9, _Drilldown10;
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
- describe('<Drilldown.Page />', () => {
35
- let consoleWarningMock;
36
- let consoleErrorMock;
37
- beforeEach(() => {
38
- // Mocking console to prevent test output pollution and expect for messages
39
- consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
40
- consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
41
- });
42
- afterEach(() => {
43
- consoleWarningMock.mockRestore();
44
- consoleErrorMock.mockRestore();
45
- });
46
- it("shouldn't render non-DrilldownPage children", async () => {
47
- (0, _react.render)(_Drilldown || (_Drilldown = (0, _jsxRuntime.jsx)(_index.Drilldown, {
48
- rootPageId: "page0",
49
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
50
- id: "page0",
51
- children: (0, _jsxRuntime.jsx)("div", {
52
- id: "testDiv",
53
- children: "Div"
54
- })
55
- })
56
- })));
57
- const nonPageChild = _react.screen.queryByText('DIV');
58
- expect(nonPageChild).not.toBeInTheDocument();
59
- });
60
- describe('header title', () => {
61
- it('should be displayed in the header', async () => {
62
- const _render = (0, _react.render)(_Drilldown2 || (_Drilldown2 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
63
- rootPageId: "page0",
64
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
65
- id: "page0",
66
- renderTitle: "HeaderTitleString",
67
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
68
- id: "option1",
69
- children: "Option"
70
- })
71
- })
72
- }))),
73
- container = _render.container;
74
- const titleContainer = container.querySelector('[id^="DrilldownHeader-Title-Label_"]');
75
- const title = _react.screen.queryByText('HeaderTitleString');
76
- expect(titleContainer).toBeInTheDocument();
77
- expect(title).toBeInTheDocument();
78
- });
79
- it('should be displayed when function is passed', async () => {
80
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
81
- rootPageId: "page0",
82
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
83
- id: "page0",
84
- renderTitle: () => 'HeaderTitleFunction',
85
- children: _Drilldown$Option || (_Drilldown$Option = (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
86
- id: "option1",
87
- children: "Option"
88
- }))
89
- })
90
- }));
91
- const title = _react.screen.queryByText('HeaderTitleFunction');
92
- expect(title).toBeInTheDocument();
93
- });
94
- it("shouldn't be displayed when function has no return value", async () => {
95
- const _render2 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
96
- rootPageId: "page0",
97
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
98
- id: "page0",
99
- renderTitle: () => null,
100
- children: _Drilldown$Option2 || (_Drilldown$Option2 = (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
101
- id: "option1",
102
- children: "Option"
103
- }))
104
- })
105
- })),
106
- container = _render2.container;
107
- const title = container.querySelector('[id^="DrilldownHeader-Title-Label_"]');
108
- const listItem = container.querySelector('li');
109
- expect(title).not.toBeInTheDocument();
110
- expect(listItem).toBeInTheDocument();
111
- });
112
- });
113
- describe('header action label', () => {
114
- it('should be displayed in the header', async () => {
115
- (0, _react.render)(_Drilldown3 || (_Drilldown3 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
116
- rootPageId: "page0",
117
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
118
- id: "page0",
119
- renderActionLabel: "HeaderActionLabelString",
120
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
121
- id: "option1",
122
- children: "Option"
123
- })
124
- })
125
- })));
126
- const actionLabel = _react.screen.queryByText('HeaderActionLabelString');
127
- expect(actionLabel).toBeInTheDocument();
128
- });
129
- it('should be displayed when function is passed', async () => {
130
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
131
- rootPageId: "page0",
132
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
133
- id: "page0",
134
- renderActionLabel: () => 'HeaderActionLabelFunction',
135
- children: _Drilldown$Option3 || (_Drilldown$Option3 = (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
136
- id: "option1",
137
- children: "Option"
138
- }))
139
- })
140
- }));
141
- const actionLabel = _react.screen.queryByText('HeaderActionLabelFunction');
142
- expect(actionLabel).toBeInTheDocument();
143
- });
144
- it("shouldn't be displayed when function has no return value", async () => {
145
- const _render3 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
146
- rootPageId: "page0",
147
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
148
- id: "page0",
149
- renderActionLabel: () => null,
150
- children: _Drilldown$Option4 || (_Drilldown$Option4 = (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
151
- id: "option1",
152
- children: "Option"
153
- }))
154
- })
155
- })),
156
- container = _render3.container;
157
- const listItem = container.querySelector('li');
158
- const title = container.querySelector('[id^="DrilldownHeader-Title-Label_"]');
159
- expect(listItem).toBeInTheDocument();
160
- expect(title).not.toBeInTheDocument();
161
- });
162
- it('should fire header action callback', async () => {
163
- const actionCallback = _vitest.vi.fn();
164
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.Drilldown, {
165
- rootPageId: "page0",
166
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
167
- id: "page0",
168
- renderActionLabel: "ActionWithCallback",
169
- onHeaderActionClicked: actionCallback,
170
- children: _Drilldown$Option5 || (_Drilldown$Option5 = (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
171
- id: "option1",
172
- children: "Option"
173
- }))
174
- })
175
- }));
176
- const actionLabel = _react.screen.getByText('ActionWithCallback');
177
- await _userEvent.default.click(actionLabel);
178
- await (0, _react.waitFor)(() => {
179
- expect(actionCallback).toHaveBeenCalled();
180
- });
181
- });
182
- });
183
- describe('header back navigation', () => {
184
- it('should not be displayed on root page', async () => {
185
- (0, _react.render)(_Drilldown4 || (_Drilldown4 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
186
- rootPageId: "page0",
187
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
188
- id: "page0",
189
- renderBackButtonLabel: "HeaderBackString",
190
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
191
- id: "option1",
192
- children: "Option"
193
- })
194
- })
195
- })));
196
- const label = _react.screen.queryByText('HeaderBackString');
197
- expect(label).not.toBeInTheDocument();
198
- });
199
- it('should be displayed on subpages', async () => {
200
- (0, _react.render)(_Drilldown5 || (_Drilldown5 = (0, _jsxRuntime.jsxs)(_index.Drilldown, {
201
- rootPageId: "page0",
202
- children: [(0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
203
- id: "page0",
204
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
205
- id: "option1",
206
- subPageId: "page2",
207
- children: "Option"
208
- })
209
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
210
- id: "page2",
211
- renderBackButtonLabel: "HeaderBackString",
212
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
213
- id: "option2",
214
- children: "Option"
215
- })
216
- })]
217
- })));
218
- const option = _react.screen.getByText('Option');
219
- await _userEvent.default.click(option);
220
- await (0, _react.waitFor)(() => {
221
- const label = _react.screen.queryByText('HeaderBackString');
222
- expect(label).toBeInTheDocument();
223
- });
224
- });
225
- it('should be displayed when function is passed, and can use former page title', async () => {
226
- const pageTitle = 'Page Title';
227
- (0, _react.render)((0, _jsxRuntime.jsxs)(_index.Drilldown, {
228
- rootPageId: "page0",
229
- children: [(0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
230
- id: "page0",
231
- renderTitle: pageTitle,
232
- children: _Drilldown$Option6 || (_Drilldown$Option6 = (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
233
- id: "option1",
234
- subPageId: "page2",
235
- children: "Option"
236
- }))
237
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
238
- id: "page2",
239
- renderBackButtonLabel: prevPageTitle => `Back to ${prevPageTitle}`,
240
- children: _Drilldown$Option7 || (_Drilldown$Option7 = (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
241
- id: "option2",
242
- children: "Option"
243
- }))
244
- })]
245
- }));
246
- const option = _react.screen.getByText('Option');
247
- await _userEvent.default.click(option);
248
- await (0, _react.waitFor)(() => {
249
- const label = _react.screen.queryByText(`Back to ${pageTitle}`);
250
- expect(label).toBeInTheDocument();
251
- });
252
- });
253
- });
254
- describe('header separator', () => {
255
- it('should not be displayed, if no item is on the header', async () => {
256
- const _render4 = (0, _react.render)(_Drilldown6 || (_Drilldown6 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
257
- rootPageId: "page0",
258
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
259
- id: "page0",
260
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
261
- id: "option1",
262
- children: "Option"
263
- })
264
- })
265
- }))),
266
- container = _render4.container;
267
- const separator = container.querySelector('[id^="DrilldownHeader-Separator_"]');
268
- expect(separator).not.toBeInTheDocument();
269
- });
270
- it('should be displayed, if there are items in the header', async () => {
271
- const _render5 = (0, _react.render)(_Drilldown7 || (_Drilldown7 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
272
- rootPageId: "page0",
273
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
274
- id: "page0",
275
- renderTitle: "Title",
276
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
277
- id: "option1",
278
- children: "Option"
279
- })
280
- })
281
- }))),
282
- container = _render5.container;
283
- const separator = container.querySelector('[id^="DrilldownHeader-Separator_"]');
284
- expect(separator).toBeInTheDocument();
285
- });
286
- it('should not be displayed, if withoutHeaderSeparator is set', async () => {
287
- const _render6 = (0, _react.render)(_Drilldown8 || (_Drilldown8 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
288
- rootPageId: "page0",
289
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
290
- id: "page0",
291
- renderTitle: "Title",
292
- withoutHeaderSeparator: true,
293
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
294
- id: "option1",
295
- children: "Option"
296
- })
297
- })
298
- }))),
299
- container = _render6.container;
300
- const separator = container.querySelector('[id^="DrilldownHeader-Separator_"]');
301
- expect(separator).not.toBeInTheDocument();
302
- });
303
- });
304
- describe('disabled prop', () => {
305
- it('should make all options disabled', async () => {
306
- (0, _react.render)(_Drilldown9 || (_Drilldown9 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
307
- rootPageId: "page0",
308
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
309
- id: "page0",
310
- renderActionLabel: "Action Label",
311
- disabled: true,
312
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
313
- id: "option1",
314
- children: "Option"
315
- })
316
- })
317
- })));
318
- const allOptions = _react.screen.getAllByRole('menuitem');
319
- allOptions.forEach(option => {
320
- expect(option).toHaveAttribute('aria-disabled', 'true');
321
- });
322
- });
323
- it("shouldn't make header Back options disabled", async () => {
324
- (0, _react.render)(_Drilldown10 || (_Drilldown10 = (0, _jsxRuntime.jsxs)(_index.Drilldown, {
325
- rootPageId: "page0",
326
- children: [(0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
327
- id: "page0",
328
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
329
- id: "option1",
330
- subPageId: "page2",
331
- children: "Option1"
332
- })
333
- }), (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
334
- id: "page2",
335
- disabled: true,
336
- renderBackButtonLabel: "HeaderBackString",
337
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Option, {
338
- id: "option2",
339
- children: "Option2"
340
- })
341
- })]
342
- })));
343
- const subPageOption = _react.screen.getByText('Option1');
344
- await _userEvent.default.click(subPageOption);
345
- await (0, _react.waitFor)(() => {
346
- const option2 = _react.screen.getByLabelText('Option2');
347
- const backOption = _react.screen.getByLabelText('HeaderBackString');
348
- expect(option2).toHaveAttribute('role', 'menuitem');
349
- expect(option2).toHaveAttribute('aria-disabled', 'true');
350
- expect(backOption).toHaveAttribute('role', 'menuitem');
351
- expect(backOption).not.toHaveAttribute('aria-disabled');
352
- });
353
- });
354
- });
355
- });
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("@testing-library/react");
4
- require("@testing-library/jest-dom");
5
- var _index = require("../../index");
6
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
7
- var _Drilldown, _Drilldown2;
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
- describe('<Drilldown.Separator />', () => {
32
- it('should render', async () => {
33
- (0, _react.render)(_Drilldown || (_Drilldown = (0, _jsxRuntime.jsx)(_index.Drilldown, {
34
- rootPageId: "page0",
35
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
36
- id: "page0",
37
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Separator, {
38
- id: "sep1",
39
- "data-testid": "separator1"
40
- })
41
- })
42
- })));
43
- const separator = _react.screen.getByTestId('separator1');
44
- expect(separator).toBeVisible();
45
- expect(separator.getAttribute('class')).toContain('-separator');
46
- });
47
- it('should not render children', async () => {
48
- (0, _react.render)(_Drilldown2 || (_Drilldown2 = (0, _jsxRuntime.jsx)(_index.Drilldown, {
49
- rootPageId: "page0",
50
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Page, {
51
- id: "page0",
52
- children: (0, _jsxRuntime.jsx)(_index.Drilldown.Separator, {
53
- id: "sep1",
54
- "data-testid": "separator1",
55
- children: "Children"
56
- })
57
- })
58
- })));
59
- const separatorChild = _react.screen.queryByText('Children');
60
- expect(separatorChild).not.toBeInTheDocument();
61
- });
62
- });