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