@instructure/ui-drilldown 10.16.1-snapshot-0 → 10.16.1

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 (51) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/es/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.js +448 -325
  3. package/es/Drilldown/DrilldownGroup/index.js +0 -1
  4. package/es/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.js +422 -309
  5. package/es/Drilldown/DrilldownOption/index.js +0 -1
  6. package/es/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.js +201 -147
  7. package/es/Drilldown/DrilldownPage/index.js +0 -1
  8. package/es/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.js +22 -17
  9. package/es/Drilldown/DrilldownSeparator/index.js +0 -1
  10. package/es/Drilldown/__examples__/Drilldown.examples.js +99 -82
  11. package/es/Drilldown/__new-tests__/Drilldown.test.js +533 -352
  12. package/es/Drilldown/index.js +144 -126
  13. package/lib/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.js +463 -340
  14. package/lib/Drilldown/DrilldownGroup/index.js +0 -1
  15. package/lib/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.js +448 -336
  16. package/lib/Drilldown/DrilldownOption/index.js +0 -1
  17. package/lib/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.js +221 -167
  18. package/lib/Drilldown/DrilldownPage/index.js +0 -2
  19. package/lib/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.js +25 -21
  20. package/lib/Drilldown/DrilldownSeparator/index.js +0 -1
  21. package/lib/Drilldown/__examples__/Drilldown.examples.js +99 -83
  22. package/lib/Drilldown/__new-tests__/Drilldown.test.js +568 -387
  23. package/lib/Drilldown/index.js +143 -126
  24. package/package.json +21 -21
  25. package/src/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.tsx +0 -1
  26. package/src/Drilldown/DrilldownGroup/index.tsx +0 -1
  27. package/src/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.tsx +1 -1
  28. package/src/Drilldown/DrilldownOption/index.tsx +0 -1
  29. package/src/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.tsx +0 -1
  30. package/src/Drilldown/DrilldownPage/index.tsx +0 -1
  31. package/src/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.tsx +0 -1
  32. package/src/Drilldown/DrilldownSeparator/index.tsx +0 -1
  33. package/src/Drilldown/__examples__/Drilldown.examples.tsx +0 -2
  34. package/src/Drilldown/__new-tests__/Drilldown.test.tsx +0 -1
  35. package/src/Drilldown/index.tsx +4 -6
  36. package/tsconfig.build.tsbuildinfo +1 -1
  37. package/types/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.d.ts.map +1 -1
  38. package/types/Drilldown/DrilldownGroup/index.d.ts +0 -1
  39. package/types/Drilldown/DrilldownGroup/index.d.ts.map +1 -1
  40. package/types/Drilldown/DrilldownOption/index.d.ts +0 -1
  41. package/types/Drilldown/DrilldownOption/index.d.ts.map +1 -1
  42. package/types/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.d.ts.map +1 -1
  43. package/types/Drilldown/DrilldownPage/index.d.ts +0 -1
  44. package/types/Drilldown/DrilldownPage/index.d.ts.map +1 -1
  45. package/types/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.d.ts.map +1 -1
  46. package/types/Drilldown/DrilldownSeparator/index.d.ts +0 -1
  47. package/types/Drilldown/DrilldownSeparator/index.d.ts.map +1 -1
  48. package/types/Drilldown/__examples__/Drilldown.examples.d.ts.map +1 -1
  49. package/types/Drilldown/__new-tests__/Drilldown.test.d.ts.map +1 -1
  50. package/types/Drilldown/index.d.ts +7 -10
  51. package/types/Drilldown/index.d.ts.map +1 -1
@@ -22,13 +22,14 @@ var _Drilldown, _Drilldown$Option, _Drilldown2, _Drilldown3, _Drilldown4, _Drill
22
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
23
  * SOFTWARE.
24
24
  */
25
- import React from 'react';
25
+
26
26
  import { render, screen, waitFor } from '@testing-library/react';
27
27
  import { vi } from 'vitest';
28
28
  import userEvent from '@testing-library/user-event';
29
29
  import '@testing-library/jest-dom';
30
30
  import { IconCheckSolid } from '@instructure/ui-icons';
31
31
  import { Drilldown } from '../../index';
32
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
32
33
  describe('<Drilldown.Option />', () => {
33
34
  let consoleWarningMock;
34
35
  let consoleErrorMock;
@@ -42,22 +43,29 @@ describe('<Drilldown.Option />', () => {
42
43
  consoleErrorMock.mockRestore();
43
44
  });
44
45
  it('should allow setting "selected" property on Options', async () => {
45
- render(_Drilldown || (_Drilldown = /*#__PURE__*/React.createElement(Drilldown, {
46
- rootPageId: "page0"
47
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
48
- id: "page0"
49
- }, /*#__PURE__*/React.createElement(Drilldown.Group, {
50
- id: "group0"
51
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
52
- id: "groupOption01"
53
- }, "Option - 1"), /*#__PURE__*/React.createElement(Drilldown.Option, {
54
- selected: true,
55
- id: "groupOption02"
56
- }, "Option - 2"), /*#__PURE__*/React.createElement(Drilldown.Option, {
57
- id: "groupOption03"
58
- }, "Option - 3"), /*#__PURE__*/React.createElement(Drilldown.Option, {
59
- id: "groupOption04"
60
- }, "Option - 4"))))));
46
+ render(_Drilldown || (_Drilldown = _jsx(Drilldown, {
47
+ rootPageId: "page0",
48
+ children: _jsx(Drilldown.Page, {
49
+ id: "page0",
50
+ children: _jsxs(Drilldown.Group, {
51
+ id: "group0",
52
+ children: [_jsx(Drilldown.Option, {
53
+ id: "groupOption01",
54
+ children: "Option - 1"
55
+ }), _jsx(Drilldown.Option, {
56
+ selected: true,
57
+ id: "groupOption02",
58
+ children: "Option - 2"
59
+ }), _jsx(Drilldown.Option, {
60
+ id: "groupOption03",
61
+ children: "Option - 3"
62
+ }), _jsx(Drilldown.Option, {
63
+ id: "groupOption04",
64
+ children: "Option - 4"
65
+ })]
66
+ })
67
+ })
68
+ })));
61
69
  const selectedOption = screen.getByLabelText('Option - 2');
62
70
  expect(selectedOption).toBeInTheDocument();
63
71
  expect(selectedOption).toHaveAttribute('id', 'groupOption02');
@@ -65,39 +73,52 @@ describe('<Drilldown.Option />', () => {
65
73
  });
66
74
  describe('id prop', () => {
67
75
  it('should throw warning the id is not provided', async () => {
68
- render(/*#__PURE__*/React.createElement(Drilldown, {
69
- rootPageId: "page0"
70
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
71
- id: "page0"
72
- }, _Drilldown$Option || (_Drilldown$Option = /*#__PURE__*/React.createElement(Drilldown.Option, null, "Option1")))));
76
+ render(_jsx(Drilldown, {
77
+ rootPageId: "page0",
78
+ children: _jsx(Drilldown.Page, {
79
+ id: "page0",
80
+ children: _Drilldown$Option || (_Drilldown$Option = _jsx(Drilldown.Option, {
81
+ children: "Option1"
82
+ }))
83
+ })
84
+ }));
73
85
  const expectedErrorMessage = "Warning: Drilldown.Option without id won't be rendered. It is needed to internally track the options.";
74
86
  expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
75
87
  });
76
88
  it('should throw warning the id is duplicated', async () => {
77
- render(_Drilldown2 || (_Drilldown2 = /*#__PURE__*/React.createElement(Drilldown, {
78
- rootPageId: "page0"
79
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
80
- id: "page0"
81
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
82
- id: "option1"
83
- }, "Option1"), /*#__PURE__*/React.createElement(Drilldown.Option, {
84
- id: "option1"
85
- }, "Option2")))));
89
+ render(_Drilldown2 || (_Drilldown2 = _jsx(Drilldown, {
90
+ rootPageId: "page0",
91
+ children: _jsxs(Drilldown.Page, {
92
+ id: "page0",
93
+ children: [_jsx(Drilldown.Option, {
94
+ id: "option1",
95
+ children: "Option1"
96
+ }), _jsx(Drilldown.Option, {
97
+ id: "option1",
98
+ children: "Option2"
99
+ })]
100
+ })
101
+ })));
86
102
  const expectedErrorMessage = 'Warning: Duplicate id: "option1"! Make sure all options have unique ids, otherwise they won\'t be rendered.';
87
103
  expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
88
104
  });
89
105
  it('should not render the options with duplicated id', async () => {
90
- render(_Drilldown3 || (_Drilldown3 = /*#__PURE__*/React.createElement(Drilldown, {
91
- rootPageId: "page0"
92
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
93
- id: "page0"
94
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
95
- id: "option1"
96
- }, "Option1"), /*#__PURE__*/React.createElement(Drilldown.Option, {
97
- id: "option1"
98
- }, "Option2"), /*#__PURE__*/React.createElement(Drilldown.Option, {
99
- id: "option1"
100
- }, "Option3")))));
106
+ render(_Drilldown3 || (_Drilldown3 = _jsx(Drilldown, {
107
+ rootPageId: "page0",
108
+ children: _jsxs(Drilldown.Page, {
109
+ id: "page0",
110
+ children: [_jsx(Drilldown.Option, {
111
+ id: "option1",
112
+ children: "Option1"
113
+ }), _jsx(Drilldown.Option, {
114
+ id: "option1",
115
+ children: "Option2"
116
+ }), _jsx(Drilldown.Option, {
117
+ id: "option1",
118
+ children: "Option3"
119
+ })]
120
+ })
121
+ })));
101
122
  const menuitems = screen.queryAllByRole('menuitem');
102
123
  const option = screen.queryByText('Option2');
103
124
  expect(menuitems.length).toBe(0);
@@ -106,25 +127,31 @@ describe('<Drilldown.Option />', () => {
106
127
  });
107
128
  describe('children function prop', () => {
108
129
  it('should throw warning if it returns nothing', async () => {
109
- render(/*#__PURE__*/React.createElement(Drilldown, {
110
- rootPageId: "page0"
111
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
112
- id: "page0"
113
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
114
- id: "option1"
115
- }, () => null))));
130
+ render(_jsx(Drilldown, {
131
+ rootPageId: "page0",
132
+ children: _jsx(Drilldown.Page, {
133
+ id: "page0",
134
+ children: _jsx(Drilldown.Option, {
135
+ id: "option1",
136
+ children: () => null
137
+ })
138
+ })
139
+ }));
116
140
  const expectedErrorMessage = 'Warning: There are no "children" prop provided for option with id: "option1", so it won\'t be rendered.';
117
141
  expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
118
142
  });
119
143
  it('should provide props as parameters', async () => {
120
144
  const childrenFunction = vi.fn(() => 'Option');
121
- render(/*#__PURE__*/React.createElement(Drilldown, {
122
- rootPageId: "page0"
123
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
124
- id: "page0"
125
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
126
- id: "option1"
127
- }, childrenFunction))));
145
+ render(_jsx(Drilldown, {
146
+ rootPageId: "page0",
147
+ children: _jsx(Drilldown.Page, {
148
+ id: "page0",
149
+ children: _jsx(Drilldown.Option, {
150
+ id: "option1",
151
+ children: childrenFunction
152
+ })
153
+ })
154
+ }));
128
155
  expect(childrenFunction).toHaveBeenCalledWith({
129
156
  id: 'option1',
130
157
  variant: 'default',
@@ -135,14 +162,17 @@ describe('<Drilldown.Option />', () => {
135
162
  describe('elementRef prop', () => {
136
163
  it('should give back to ref for the option wrapper (Options.Item)', async () => {
137
164
  const elementRef = vi.fn();
138
- const _render = render(/*#__PURE__*/React.createElement(Drilldown, {
139
- rootPageId: "page0"
140
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
141
- id: "page0"
142
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
143
- id: "option1",
144
- elementRef: elementRef
145
- }, "Option")))),
165
+ const _render = render(_jsx(Drilldown, {
166
+ rootPageId: "page0",
167
+ children: _jsx(Drilldown.Page, {
168
+ id: "page0",
169
+ children: _jsx(Drilldown.Option, {
170
+ id: "option1",
171
+ elementRef: elementRef,
172
+ children: "Option"
173
+ })
174
+ })
175
+ })),
146
176
  container = _render.container;
147
177
  const option = container.querySelector('li');
148
178
  expect(elementRef).toHaveBeenCalledWith(option);
@@ -150,28 +180,34 @@ describe('<Drilldown.Option />', () => {
150
180
  });
151
181
  describe('subPageId prop', () => {
152
182
  it('should display arrow icon', async () => {
153
- const _render2 = render(_Drilldown4 || (_Drilldown4 = /*#__PURE__*/React.createElement(Drilldown, {
154
- rootPageId: "page0"
155
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
156
- id: "page0"
157
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
158
- id: "option1",
159
- subPageId: "page1"
160
- }, "Option"))))),
183
+ const _render2 = render(_Drilldown4 || (_Drilldown4 = _jsx(Drilldown, {
184
+ rootPageId: "page0",
185
+ children: _jsx(Drilldown.Page, {
186
+ id: "page0",
187
+ children: _jsx(Drilldown.Option, {
188
+ id: "option1",
189
+ subPageId: "page1",
190
+ children: "Option"
191
+ })
192
+ })
193
+ }))),
161
194
  container = _render2.container;
162
195
  const icon = container.querySelector('svg');
163
196
  expect(icon).toBeInTheDocument();
164
197
  expect(icon).toHaveAttribute('name', 'IconArrowOpenEnd');
165
198
  });
166
199
  it('should indicate subpage fo SR', async () => {
167
- render(_Drilldown5 || (_Drilldown5 = /*#__PURE__*/React.createElement(Drilldown, {
168
- rootPageId: "page0"
169
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
170
- id: "page0"
171
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
172
- id: "option1",
173
- subPageId: "page1"
174
- }, "Option")))));
200
+ render(_Drilldown5 || (_Drilldown5 = _jsx(Drilldown, {
201
+ rootPageId: "page0",
202
+ children: _jsx(Drilldown.Page, {
203
+ id: "page0",
204
+ children: _jsx(Drilldown.Option, {
205
+ id: "option1",
206
+ subPageId: "page1",
207
+ children: "Option"
208
+ })
209
+ })
210
+ })));
175
211
  const option = screen.getByLabelText('Option');
176
212
  expect(option).toHaveAttribute('role', 'button');
177
213
  expect(option).toHaveAttribute('aria-haspopup', 'true');
@@ -179,42 +215,51 @@ describe('<Drilldown.Option />', () => {
179
215
  });
180
216
  describe('disabled prop', () => {
181
217
  it('should mark option as disabled for SR', async () => {
182
- render(_Drilldown6 || (_Drilldown6 = /*#__PURE__*/React.createElement(Drilldown, {
183
- rootPageId: "page0"
184
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
185
- id: "page0"
186
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
187
- id: "option1",
188
- disabled: true
189
- }, "Option")))));
218
+ render(_Drilldown6 || (_Drilldown6 = _jsx(Drilldown, {
219
+ rootPageId: "page0",
220
+ children: _jsx(Drilldown.Page, {
221
+ id: "page0",
222
+ children: _jsx(Drilldown.Option, {
223
+ id: "option1",
224
+ disabled: true,
225
+ children: "Option"
226
+ })
227
+ })
228
+ })));
190
229
  const option = screen.getByLabelText('Option');
191
230
  expect(option).toHaveAttribute('aria-disabled', 'true');
192
231
  });
193
232
  });
194
233
  describe('href prop', () => {
195
234
  it('should display option as link', async () => {
196
- render(_Drilldown7 || (_Drilldown7 = /*#__PURE__*/React.createElement(Drilldown, {
197
- rootPageId: "page0"
198
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
199
- id: "page0"
200
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
201
- id: "option1",
202
- href: "/helloWorld"
203
- }, "Option")))));
235
+ render(_Drilldown7 || (_Drilldown7 = _jsx(Drilldown, {
236
+ rootPageId: "page0",
237
+ children: _jsx(Drilldown.Page, {
238
+ id: "page0",
239
+ children: _jsx(Drilldown.Option, {
240
+ id: "option1",
241
+ href: "/helloWorld",
242
+ children: "Option"
243
+ })
244
+ })
245
+ })));
204
246
  const option = screen.getByLabelText('Option');
205
247
  expect(option.tagName).toBe('A');
206
248
  expect(option).toHaveAttribute('href', '/helloWorld');
207
249
  });
208
250
  it('should throw warning if subPageId is provided too', async () => {
209
- render(_Drilldown8 || (_Drilldown8 = /*#__PURE__*/React.createElement(Drilldown, {
210
- rootPageId: "page0"
211
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
212
- id: "page0"
213
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
214
- id: "option1",
215
- href: "/helloWorld",
216
- subPageId: "page1"
217
- }, "Option")))));
251
+ render(_Drilldown8 || (_Drilldown8 = _jsx(Drilldown, {
252
+ rootPageId: "page0",
253
+ children: _jsx(Drilldown.Page, {
254
+ id: "page0",
255
+ children: _jsx(Drilldown.Option, {
256
+ id: "option1",
257
+ href: "/helloWorld",
258
+ subPageId: "page1",
259
+ children: "Option"
260
+ })
261
+ })
262
+ })));
218
263
  const option = screen.getByLabelText('Option');
219
264
  const expectedErrorMessage = 'Warning: Drilldown.Option with id "option1" has subPageId, so it will ignore the "href" property.';
220
265
  expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
@@ -222,17 +267,21 @@ describe('<Drilldown.Option />', () => {
222
267
  expect(option).not.toHaveAttribute('href');
223
268
  });
224
269
  it('should throw warning if option is in selectable group', async () => {
225
- render(_Drilldown9 || (_Drilldown9 = /*#__PURE__*/React.createElement(Drilldown, {
226
- rootPageId: "page0"
227
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
228
- id: "page0"
229
- }, /*#__PURE__*/React.createElement(Drilldown.Group, {
230
- id: "group0",
231
- selectableType: "multiple"
232
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
233
- id: "groupOption01",
234
- href: "/helloWorld"
235
- }, "Option"))))));
270
+ render(_Drilldown9 || (_Drilldown9 = _jsx(Drilldown, {
271
+ rootPageId: "page0",
272
+ children: _jsx(Drilldown.Page, {
273
+ id: "page0",
274
+ children: _jsx(Drilldown.Group, {
275
+ id: "group0",
276
+ selectableType: "multiple",
277
+ children: _jsx(Drilldown.Option, {
278
+ id: "groupOption01",
279
+ href: "/helloWorld",
280
+ children: "Option"
281
+ })
282
+ })
283
+ })
284
+ })));
236
285
  const option = screen.getByLabelText('Option');
237
286
  const expectedErrorMessage = 'Warning: Drilldown.Option with id "groupOption01" is in a selectable group, so it will ignore the "href" property.';
238
287
  expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
@@ -242,43 +291,52 @@ describe('<Drilldown.Option />', () => {
242
291
  });
243
292
  describe('as prop', () => {
244
293
  it('should render option as `li` by default', async () => {
245
- render(_Drilldown10 || (_Drilldown10 = /*#__PURE__*/React.createElement(Drilldown, {
246
- rootPageId: "page0"
247
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
248
- id: "page0"
249
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
250
- id: "option1"
251
- }, "Option")))));
294
+ render(_Drilldown10 || (_Drilldown10 = _jsx(Drilldown, {
295
+ rootPageId: "page0",
296
+ children: _jsx(Drilldown.Page, {
297
+ id: "page0",
298
+ children: _jsx(Drilldown.Option, {
299
+ id: "option1",
300
+ children: "Option"
301
+ })
302
+ })
303
+ })));
252
304
  const option = screen.getByLabelText('Option');
253
305
  const wrapper = option.parentElement;
254
306
  expect(option).toHaveAttribute('id', 'option1');
255
307
  expect(wrapper === null || wrapper === void 0 ? void 0 : wrapper.tagName).toBe('LI');
256
308
  });
257
309
  it('should force option to be `li` while the parent is "ul" or "ol"', async () => {
258
- render(_Drilldown11 || (_Drilldown11 = /*#__PURE__*/React.createElement(Drilldown, {
310
+ render(_Drilldown11 || (_Drilldown11 = _jsx(Drilldown, {
259
311
  rootPageId: "page0",
260
- as: "ol"
261
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
262
- id: "page0"
263
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
264
- id: "option1",
265
- as: "div"
266
- }, "Option")))));
312
+ as: "ol",
313
+ children: _jsx(Drilldown.Page, {
314
+ id: "page0",
315
+ children: _jsx(Drilldown.Option, {
316
+ id: "option1",
317
+ as: "div",
318
+ children: "Option"
319
+ })
320
+ })
321
+ })));
267
322
  const option = screen.getByLabelText('Option');
268
323
  const wrapper = option.parentElement;
269
324
  expect(option).toHaveAttribute('id', 'option1');
270
325
  expect(wrapper === null || wrapper === void 0 ? void 0 : wrapper.tagName).toBe('LI');
271
326
  });
272
327
  it('should render option as specified html element, when the parent in non-list element', async () => {
273
- render(_Drilldown12 || (_Drilldown12 = /*#__PURE__*/React.createElement(Drilldown, {
328
+ render(_Drilldown12 || (_Drilldown12 = _jsx(Drilldown, {
274
329
  rootPageId: "page0",
275
- as: "div"
276
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
277
- id: "page0"
278
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
279
- id: "option1",
280
- as: "div"
281
- }, "Option")))));
330
+ as: "div",
331
+ children: _jsx(Drilldown.Page, {
332
+ id: "page0",
333
+ children: _jsx(Drilldown.Option, {
334
+ id: "option1",
335
+ as: "div",
336
+ children: "Option"
337
+ })
338
+ })
339
+ })));
282
340
  const option = screen.getByLabelText('Option');
283
341
  const wrapper = option.parentElement;
284
342
  expect(option).toHaveAttribute('id', 'option1');
@@ -287,39 +345,48 @@ describe('<Drilldown.Option />', () => {
287
345
  });
288
346
  describe('role prop', () => {
289
347
  it('should be "menuitem" by default', async () => {
290
- render(_Drilldown13 || (_Drilldown13 = /*#__PURE__*/React.createElement(Drilldown, {
291
- rootPageId: "page0"
292
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
293
- id: "page0"
294
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
295
- id: "option1"
296
- }, "Option")))));
348
+ render(_Drilldown13 || (_Drilldown13 = _jsx(Drilldown, {
349
+ rootPageId: "page0",
350
+ children: _jsx(Drilldown.Page, {
351
+ id: "page0",
352
+ children: _jsx(Drilldown.Option, {
353
+ id: "option1",
354
+ children: "Option"
355
+ })
356
+ })
357
+ })));
297
358
  const option = screen.getByLabelText('Option');
298
359
  expect(option).toHaveAttribute('role', 'menuitem');
299
360
  });
300
361
  it('should be applied on prop', async () => {
301
- render(_Drilldown14 || (_Drilldown14 = /*#__PURE__*/React.createElement(Drilldown, {
302
- rootPageId: "page0"
303
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
304
- id: "page0"
305
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
306
- id: "option1",
307
- role: "presentation"
308
- }, "Option")))));
362
+ render(_Drilldown14 || (_Drilldown14 = _jsx(Drilldown, {
363
+ rootPageId: "page0",
364
+ children: _jsx(Drilldown.Page, {
365
+ id: "page0",
366
+ children: _jsx(Drilldown.Option, {
367
+ id: "option1",
368
+ role: "presentation",
369
+ children: "Option"
370
+ })
371
+ })
372
+ })));
309
373
  const option = screen.getByLabelText('Option');
310
374
  expect(option).toHaveAttribute('role', 'presentation');
311
375
  });
312
376
  });
313
377
  describe('renderLabelInfo prop', () => {
314
378
  it('should display tag next to the label', async () => {
315
- const _render3 = render(_Drilldown15 || (_Drilldown15 = /*#__PURE__*/React.createElement(Drilldown, {
316
- rootPageId: "page0"
317
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
318
- id: "page0"
319
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
320
- id: "option1",
321
- renderLabelInfo: "Info"
322
- }, "Option"))))),
379
+ const _render3 = render(_Drilldown15 || (_Drilldown15 = _jsx(Drilldown, {
380
+ rootPageId: "page0",
381
+ children: _jsx(Drilldown.Page, {
382
+ id: "page0",
383
+ children: _jsx(Drilldown.Option, {
384
+ id: "option1",
385
+ renderLabelInfo: "Info",
386
+ children: "Option"
387
+ })
388
+ })
389
+ }))),
323
390
  container = _render3.container;
324
391
  const tag = container.querySelector('[class$="optionLabelInfo"]');
325
392
  expect(tag).toBeInTheDocument();
@@ -327,14 +394,17 @@ describe('<Drilldown.Option />', () => {
327
394
  });
328
395
  it('as function should have option props as params', async () => {
329
396
  const infoFunction = vi.fn(() => 'Info');
330
- render(/*#__PURE__*/React.createElement(Drilldown, {
331
- rootPageId: "page0"
332
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
333
- id: "page0"
334
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
335
- id: "option1",
336
- renderLabelInfo: infoFunction
337
- }, "Option"))));
397
+ render(_jsx(Drilldown, {
398
+ rootPageId: "page0",
399
+ children: _jsx(Drilldown.Page, {
400
+ id: "page0",
401
+ children: _jsx(Drilldown.Option, {
402
+ id: "option1",
403
+ renderLabelInfo: infoFunction,
404
+ children: "Option"
405
+ })
406
+ })
407
+ }));
338
408
  expect(infoFunction).toHaveBeenCalledWith({
339
409
  variant: 'default',
340
410
  vAlign: 'start',
@@ -346,29 +416,35 @@ describe('<Drilldown.Option />', () => {
346
416
  });
347
417
  describe('renderBeforeLabel prop', () => {
348
418
  it('should display icon before the label', async () => {
349
- const _render4 = render(_Drilldown16 || (_Drilldown16 = /*#__PURE__*/React.createElement(Drilldown, {
350
- rootPageId: "page0"
351
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
352
- id: "page0"
353
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
354
- id: "option1",
355
- renderBeforeLabel: /*#__PURE__*/React.createElement(IconCheckSolid, null)
356
- }, "Option"))))),
419
+ const _render4 = render(_Drilldown16 || (_Drilldown16 = _jsx(Drilldown, {
420
+ rootPageId: "page0",
421
+ children: _jsx(Drilldown.Page, {
422
+ id: "page0",
423
+ children: _jsx(Drilldown.Option, {
424
+ id: "option1",
425
+ renderBeforeLabel: _jsx(IconCheckSolid, {}),
426
+ children: "Option"
427
+ })
428
+ })
429
+ }))),
357
430
  container = _render4.container;
358
431
  const icon = container.querySelector('svg');
359
432
  expect(icon).toBeInTheDocument();
360
433
  expect(icon).toHaveAttribute('name', 'IconCheck');
361
434
  });
362
435
  it('as function should have option props as params', async () => {
363
- const beforeLabelFunction = vi.fn(() => _IconCheckSolid || (_IconCheckSolid = /*#__PURE__*/React.createElement(IconCheckSolid, null)));
364
- render(/*#__PURE__*/React.createElement(Drilldown, {
365
- rootPageId: "page0"
366
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
367
- id: "page0"
368
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
369
- id: "option1",
370
- renderBeforeLabel: beforeLabelFunction
371
- }, "Option"))));
436
+ const beforeLabelFunction = vi.fn(() => _IconCheckSolid || (_IconCheckSolid = _jsx(IconCheckSolid, {})));
437
+ render(_jsx(Drilldown, {
438
+ rootPageId: "page0",
439
+ children: _jsx(Drilldown.Page, {
440
+ id: "page0",
441
+ children: _jsx(Drilldown.Option, {
442
+ id: "option1",
443
+ renderBeforeLabel: beforeLabelFunction,
444
+ children: "Option"
445
+ })
446
+ })
447
+ }));
372
448
  expect(beforeLabelFunction).toHaveBeenCalledWith(expect.objectContaining({
373
449
  variant: 'default',
374
450
  vAlign: 'start',
@@ -378,46 +454,56 @@ describe('<Drilldown.Option />', () => {
378
454
  }), expect.any(Object));
379
455
  });
380
456
  it('should throw warning if it is in selectable group', async () => {
381
- render(_Drilldown17 || (_Drilldown17 = /*#__PURE__*/React.createElement(Drilldown, {
382
- rootPageId: "page0"
383
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
384
- id: "page0"
385
- }, /*#__PURE__*/React.createElement(Drilldown.Group, {
386
- id: "group1",
387
- selectableType: "multiple"
388
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
389
- id: "groupOption1",
390
- renderBeforeLabel: "Before"
391
- }, "Option"))))));
457
+ render(_Drilldown17 || (_Drilldown17 = _jsx(Drilldown, {
458
+ rootPageId: "page0",
459
+ children: _jsx(Drilldown.Page, {
460
+ id: "page0",
461
+ children: _jsx(Drilldown.Group, {
462
+ id: "group1",
463
+ selectableType: "multiple",
464
+ children: _jsx(Drilldown.Option, {
465
+ id: "groupOption1",
466
+ renderBeforeLabel: "Before",
467
+ children: "Option"
468
+ })
469
+ })
470
+ })
471
+ })));
392
472
  const expectedErrorMessage = 'Warning: The prop "renderBeforeLabel" is reserved on item with id: "groupOption1". When this option is a selectable member of a Drilldown.Group, selection indicator will render before the label.';
393
473
  expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
394
474
  });
395
475
  });
396
476
  describe('renderAfterLabel prop', () => {
397
477
  it('should display icon before the label', async () => {
398
- const _render5 = render(_Drilldown18 || (_Drilldown18 = /*#__PURE__*/React.createElement(Drilldown, {
399
- rootPageId: "page0"
400
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
401
- id: "page0"
402
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
403
- id: "option1",
404
- renderAfterLabel: /*#__PURE__*/React.createElement(IconCheckSolid, null)
405
- }, "Option"))))),
478
+ const _render5 = render(_Drilldown18 || (_Drilldown18 = _jsx(Drilldown, {
479
+ rootPageId: "page0",
480
+ children: _jsx(Drilldown.Page, {
481
+ id: "page0",
482
+ children: _jsx(Drilldown.Option, {
483
+ id: "option1",
484
+ renderAfterLabel: _jsx(IconCheckSolid, {}),
485
+ children: "Option"
486
+ })
487
+ })
488
+ }))),
406
489
  container = _render5.container;
407
490
  const icon = container.querySelector('svg');
408
491
  expect(icon).toBeInTheDocument();
409
492
  expect(icon).toHaveAttribute('name', 'IconCheck');
410
493
  });
411
494
  it('as function should have option props as params', async () => {
412
- const beforeLabelFunction = vi.fn(() => _IconCheckSolid2 || (_IconCheckSolid2 = /*#__PURE__*/React.createElement(IconCheckSolid, null)));
413
- render(/*#__PURE__*/React.createElement(Drilldown, {
414
- rootPageId: "page0"
415
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
416
- id: "page0"
417
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
418
- id: "option1",
419
- renderAfterLabel: beforeLabelFunction
420
- }, "Option"))));
495
+ const beforeLabelFunction = vi.fn(() => _IconCheckSolid2 || (_IconCheckSolid2 = _jsx(IconCheckSolid, {})));
496
+ render(_jsx(Drilldown, {
497
+ rootPageId: "page0",
498
+ children: _jsx(Drilldown.Page, {
499
+ id: "page0",
500
+ children: _jsx(Drilldown.Option, {
501
+ id: "option1",
502
+ renderAfterLabel: beforeLabelFunction,
503
+ children: "Option"
504
+ })
505
+ })
506
+ }));
421
507
  expect(beforeLabelFunction).toHaveBeenCalledWith(expect.objectContaining({
422
508
  variant: 'default',
423
509
  vAlign: 'start',
@@ -427,56 +513,68 @@ describe('<Drilldown.Option />', () => {
427
513
  }), expect.any(Object));
428
514
  });
429
515
  it('should throw warning if it has subPageId', async () => {
430
- render(_Drilldown19 || (_Drilldown19 = /*#__PURE__*/React.createElement(Drilldown, {
431
- rootPageId: "page0"
432
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
433
- id: "page0"
434
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
435
- id: "option1",
436
- subPageId: "page1",
437
- renderAfterLabel: "after"
438
- }, "Option")))));
516
+ render(_Drilldown19 || (_Drilldown19 = _jsx(Drilldown, {
517
+ rootPageId: "page0",
518
+ children: _jsx(Drilldown.Page, {
519
+ id: "page0",
520
+ children: _jsx(Drilldown.Option, {
521
+ id: "option1",
522
+ subPageId: "page1",
523
+ renderAfterLabel: "after",
524
+ children: "Option"
525
+ })
526
+ })
527
+ })));
439
528
  const expectedErrorMessage = 'Warning: The prop "renderAfterLabel" is reserved on item with id: "option1". When it has "subPageId" provided, a navigation arrow will render after the label.';
440
529
  expect(consoleWarningMock).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
441
530
  });
442
531
  });
443
532
  describe('description prop', () => {
444
533
  it('should display description under the option', async () => {
445
- render(_Drilldown20 || (_Drilldown20 = /*#__PURE__*/React.createElement(Drilldown, {
446
- rootPageId: "page0"
447
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
448
- id: "page0"
449
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
450
- id: "option1",
451
- description: "This is a description."
452
- }, "Option")))));
534
+ render(_Drilldown20 || (_Drilldown20 = _jsx(Drilldown, {
535
+ rootPageId: "page0",
536
+ children: _jsx(Drilldown.Page, {
537
+ id: "page0",
538
+ children: _jsx(Drilldown.Option, {
539
+ id: "option1",
540
+ description: "This is a description.",
541
+ children: "Option"
542
+ })
543
+ })
544
+ })));
453
545
  const description = screen.getByText('This is a description.');
454
546
  expect(description).toBeInTheDocument();
455
547
  });
456
548
  it('as a function should display description under the option', async () => {
457
- render(/*#__PURE__*/React.createElement(Drilldown, {
458
- rootPageId: "page0"
459
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
460
- id: "page0"
461
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
462
- id: "option1",
463
- description: () => 'This is a description.'
464
- }, "Option"))));
549
+ render(_jsx(Drilldown, {
550
+ rootPageId: "page0",
551
+ children: _jsx(Drilldown.Page, {
552
+ id: "page0",
553
+ children: _jsx(Drilldown.Option, {
554
+ id: "option1",
555
+ description: () => 'This is a description.',
556
+ children: "Option"
557
+ })
558
+ })
559
+ }));
465
560
  const description = screen.getByText('This is a description.');
466
561
  expect(description).toBeInTheDocument();
467
562
  });
468
563
  });
469
564
  describe('descriptionRole prop', () => {
470
565
  it('should set the role of description', async () => {
471
- render(_Drilldown21 || (_Drilldown21 = /*#__PURE__*/React.createElement(Drilldown, {
472
- rootPageId: "page0"
473
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
474
- id: "page0"
475
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
476
- id: "option1",
477
- description: "This is a description.",
478
- descriptionRole: "button"
479
- }, "Option")))));
566
+ render(_Drilldown21 || (_Drilldown21 = _jsx(Drilldown, {
567
+ rootPageId: "page0",
568
+ children: _jsx(Drilldown.Page, {
569
+ id: "page0",
570
+ children: _jsx(Drilldown.Option, {
571
+ id: "option1",
572
+ description: "This is a description.",
573
+ descriptionRole: "button",
574
+ children: "Option"
575
+ })
576
+ })
577
+ })));
480
578
  const description = screen.getByText('This is a description.');
481
579
  expect(description).toHaveAttribute('role', 'button');
482
580
  });
@@ -484,14 +582,17 @@ describe('<Drilldown.Option />', () => {
484
582
  describe('onOptionClick callback', () => {
485
583
  it('should fire on click with correct params', async () => {
486
584
  const onOptionClick = vi.fn();
487
- render(/*#__PURE__*/React.createElement(Drilldown, {
488
- rootPageId: "page0"
489
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
490
- id: "page0"
491
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
492
- id: "option1",
493
- onOptionClick: onOptionClick
494
- }, "Option"))));
585
+ render(_jsx(Drilldown, {
586
+ rootPageId: "page0",
587
+ children: _jsx(Drilldown.Page, {
588
+ id: "page0",
589
+ children: _jsx(Drilldown.Option, {
590
+ id: "option1",
591
+ onOptionClick: onOptionClick,
592
+ children: "Option"
593
+ })
594
+ })
595
+ }));
495
596
  const option = screen.getByText('Option');
496
597
  await userEvent.click(option);
497
598
  await waitFor(() => {
@@ -506,18 +607,21 @@ describe('<Drilldown.Option />', () => {
506
607
  });
507
608
  });
508
609
  it('should provide goToPreviousPage method that throws a warning, if there is no previous page', async () => {
509
- render(/*#__PURE__*/React.createElement(Drilldown, {
510
- rootPageId: "page0"
511
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
512
- id: "page0"
513
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
514
- id: "option01",
515
- onOptionClick: (_e, {
516
- goToPreviousPage
517
- }) => {
518
- goToPreviousPage();
519
- }
520
- }, "Option"))));
610
+ render(_jsx(Drilldown, {
611
+ rootPageId: "page0",
612
+ children: _jsx(Drilldown.Page, {
613
+ id: "page0",
614
+ children: _jsx(Drilldown.Option, {
615
+ id: "option01",
616
+ onOptionClick: (_e, {
617
+ goToPreviousPage
618
+ }) => {
619
+ goToPreviousPage();
620
+ },
621
+ children: "Option"
622
+ })
623
+ })
624
+ }));
521
625
  const option = screen.getByText('Option');
522
626
  await userEvent.click(option);
523
627
  await waitFor(() => {
@@ -527,18 +631,21 @@ describe('<Drilldown.Option />', () => {
527
631
  });
528
632
  describe('provide goToPage method', () => {
529
633
  it("should throws warning if page doesn't exist", async () => {
530
- render(/*#__PURE__*/React.createElement(Drilldown, {
531
- rootPageId: "page0"
532
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
533
- id: "page0"
534
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
535
- id: "option01",
536
- onOptionClick: (_e, {
537
- goToPage
538
- }) => {
539
- goToPage('page1');
540
- }
541
- }, "Option"))));
634
+ render(_jsx(Drilldown, {
635
+ rootPageId: "page0",
636
+ children: _jsx(Drilldown.Page, {
637
+ id: "page0",
638
+ children: _jsx(Drilldown.Option, {
639
+ id: "option01",
640
+ onOptionClick: (_e, {
641
+ goToPage
642
+ }) => {
643
+ goToPage('page1');
644
+ },
645
+ children: "Option"
646
+ })
647
+ })
648
+ }));
542
649
  const option = screen.getByText('Option');
543
650
  await userEvent.click(option);
544
651
  await waitFor(() => {
@@ -547,19 +654,22 @@ describe('<Drilldown.Option />', () => {
547
654
  });
548
655
  });
549
656
  it('should throws warning if if no page id is provided', async () => {
550
- render(/*#__PURE__*/React.createElement(Drilldown, {
551
- rootPageId: "page0"
552
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
553
- id: "page0"
554
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
555
- id: "option01",
556
- onOptionClick: (_e, {
557
- goToPage
558
- }) => {
559
- // @ts-expect-error we want this to fail
560
- goToPage();
561
- }
562
- }, "Option"))));
657
+ render(_jsx(Drilldown, {
658
+ rootPageId: "page0",
659
+ children: _jsx(Drilldown.Page, {
660
+ id: "page0",
661
+ children: _jsx(Drilldown.Option, {
662
+ id: "option01",
663
+ onOptionClick: (_e, {
664
+ goToPage
665
+ }) => {
666
+ // @ts-expect-error we want this to fail
667
+ goToPage();
668
+ },
669
+ children: "Option"
670
+ })
671
+ })
672
+ }));
563
673
  const option = screen.getByText('Option');
564
674
  await userEvent.click(option);
565
675
  await waitFor(() => {
@@ -568,21 +678,24 @@ describe('<Drilldown.Option />', () => {
568
678
  });
569
679
  });
570
680
  it('should throws warning if parameter is not string', async () => {
571
- render(/*#__PURE__*/React.createElement(Drilldown, {
572
- rootPageId: "page0"
573
- }, /*#__PURE__*/React.createElement(Drilldown.Page, {
574
- id: "page0"
575
- }, /*#__PURE__*/React.createElement(Drilldown.Option, {
576
- id: "option01",
577
- onOptionClick: (_e, {
578
- goToPage
579
- }) => {
580
- // @ts-expect-error we want this to fail
581
- goToPage({
582
- page: 'page1'
583
- });
584
- }
585
- }, "Option"))));
681
+ render(_jsx(Drilldown, {
682
+ rootPageId: "page0",
683
+ children: _jsx(Drilldown.Page, {
684
+ id: "page0",
685
+ children: _jsx(Drilldown.Option, {
686
+ id: "option01",
687
+ onOptionClick: (_e, {
688
+ goToPage
689
+ }) => {
690
+ // @ts-expect-error we want this to fail
691
+ goToPage({
692
+ page: 'page1'
693
+ });
694
+ },
695
+ children: "Option"
696
+ })
697
+ })
698
+ }));
586
699
  const option = screen.getByText('Option');
587
700
  await userEvent.click(option);
588
701
  await waitFor(() => {