vue3-extended-multiselect 0.0.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/.browserslistrc +3 -0
- package/.eslintrc.js +29 -0
- package/CHANGELOG.md +9 -0
- package/README.md +696 -0
- package/babel.config.js +5 -0
- package/index.js +3 -0
- package/jest.config.js +57 -0
- package/package.json +44 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/src/assets/base-arrow.svg +70 -0
- package/src/assets/cancel.svg +35 -0
- package/src/assets/circle-arrow.svg +7 -0
- package/src/assets/double-arrow.svg +39 -0
- package/src/assets/inner-arrow.svg +8 -0
- package/src/assets/loader.svg +6 -0
- package/src/assets/triangle-arrow.svg +72 -0
- package/src/assets/triangle-circle-arrow.svg +38 -0
- package/src/assets/wide-arrow.svg +72 -0
- package/src/components/ExtendedMultiselectCancel.vue +142 -0
- package/src/components/ExtendedMultiselectInput.vue +619 -0
- package/src/components/ExtendedMultiselectLoader.vue +176 -0
- package/src/components/ExtendedMultiselectMultiple.vue +292 -0
- package/src/components/ExtendedMultiselectOptions.vue +1088 -0
- package/src/components/ExtendedMultiselectToggle.vue +255 -0
- package/src/components/Vue3ExtendedMultiselect.vue +1651 -0
- package/src/composition/cancel.js +31 -0
- package/src/composition/labels.js +40 -0
- package/src/composition/preselected-options.js +67 -0
- package/src/composition/search-value.js +34 -0
- package/src/composition/sizes.js +43 -0
- package/src/composition/toggle.js +34 -0
- package/src/sass/animations.sass +13 -0
- package/src/sass/main.sass +340 -0
- package/src/sass/mixins.sass +40 -0
- package/src/sass/variables.sass +37 -0
- package/src/sets/sets.js +100 -0
- package/tests/unit/events.spec.js +136 -0
- package/tests/unit/props.spec.js +1041 -0
- package/tests/utils/mount.js +38 -0
- package/tests/utils/stubs.js +1 -0
- package/tests/utils/utils.js +21 -0
- package/typings/vue3-extended-multiselect.d.ts +34 -0
|
@@ -0,0 +1,1041 @@
|
|
|
1
|
+
import { fireEvent } from "@testing-library/dom";
|
|
2
|
+
import {
|
|
3
|
+
mountComponent,
|
|
4
|
+
wrapperProvides,
|
|
5
|
+
wrapperSlots,
|
|
6
|
+
SEARCH_PATTERN,
|
|
7
|
+
NO_OPTIONS_PATTERN,
|
|
8
|
+
FIRST_OPTION_PATTERN,
|
|
9
|
+
} from "../utils/mount";
|
|
10
|
+
import {
|
|
11
|
+
mockOptionSelection,
|
|
12
|
+
expandOptionsList,
|
|
13
|
+
createNewOptionsWrapper,
|
|
14
|
+
} from "../utils/utils";
|
|
15
|
+
|
|
16
|
+
import Vue3ExtendedMultiselect from "../../src/components/Vue3ExtendedMultiselect.vue";
|
|
17
|
+
import ExtendedMultiselectMultiple from "../../src/components/ExtendedMultiselectMultiple.vue";
|
|
18
|
+
import ExtendedMultiselectLoader from "../../src/components/ExtendedMultiselectLoader.vue";
|
|
19
|
+
import ExtendedMultiselectInput from "../../src/components/ExtendedMultiselectInput.vue";
|
|
20
|
+
import ExtendedMultiselectOptions from "../../src/components/ExtendedMultiselectOptions.vue";
|
|
21
|
+
import ExtendedMultiselectToggle from "../../src/components/ExtendedMultiselectToggle.vue";
|
|
22
|
+
|
|
23
|
+
let wrapper;
|
|
24
|
+
|
|
25
|
+
describe("props", () => {
|
|
26
|
+
it("correctly handles 'autoSelectCreatedOption' prop value", async () => {
|
|
27
|
+
const propsData = {
|
|
28
|
+
autoSelectCreatedOption: true,
|
|
29
|
+
createOnTheGo: true,
|
|
30
|
+
defaultExpanded: true,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
wrapper = await mountComponent(
|
|
34
|
+
Vue3ExtendedMultiselect,
|
|
35
|
+
false,
|
|
36
|
+
propsData,
|
|
37
|
+
wrapperProvides(globalThis.SEARCH_VALUE, SEARCH_PATTERN),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
await fireEvent.mouseDown(createNewOptionsWrapper(wrapper).element);
|
|
41
|
+
|
|
42
|
+
const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
|
|
43
|
+
const selectedOption = inputWrapper.find(".extended__multiselect-block").find("span");
|
|
44
|
+
|
|
45
|
+
expect(selectedOption.text()).toEqual(globalThis.SEARCH_VALUE);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
it("correctly handles 'clearBySelectWhenMultiple' prop value", async () => {
|
|
50
|
+
const propsData = {
|
|
51
|
+
clearBySelectWhenMultiple: true,
|
|
52
|
+
defaultExpanded: true,
|
|
53
|
+
multiple: true,
|
|
54
|
+
options: globalThis.OPTIONS,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
58
|
+
|
|
59
|
+
const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput).find("input");
|
|
60
|
+
|
|
61
|
+
await inputWrapper.setValue(globalThis.SEARCH_VALUE_WITH_RESULTS);
|
|
62
|
+
await mockOptionSelection(wrapper);
|
|
63
|
+
|
|
64
|
+
expect(inputWrapper.element.value).toHaveLength(0);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
it("correctly handles 'createOnTheGo' prop value", async () => {
|
|
69
|
+
const propsData = {
|
|
70
|
+
createOnTheGo: true,
|
|
71
|
+
defaultExpanded: true,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
wrapper = await mountComponent(
|
|
75
|
+
Vue3ExtendedMultiselect,
|
|
76
|
+
false,
|
|
77
|
+
propsData,
|
|
78
|
+
wrapperProvides(globalThis.SEARCH_VALUE, SEARCH_PATTERN),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
expect(createNewOptionsWrapper(wrapper).exists()).toBeTruthy();
|
|
82
|
+
expect(createNewOptionsWrapper(wrapper).isVisible()).toBeTruthy();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
it("correctly handles 'defaultExpanded' prop value", async (done) => {
|
|
87
|
+
expect.assertions(3);
|
|
88
|
+
|
|
89
|
+
const propsData = {
|
|
90
|
+
defaultExpanded: true,
|
|
91
|
+
options: async () => await Promise.resolve(globalThis.OPTIONS),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
95
|
+
|
|
96
|
+
let optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
97
|
+
|
|
98
|
+
expect(optionsWrapper.exists()).toBeFalsy();
|
|
99
|
+
|
|
100
|
+
propsData.options = globalThis.OPTIONS;
|
|
101
|
+
|
|
102
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
103
|
+
|
|
104
|
+
process.nextTick(() => {
|
|
105
|
+
optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
106
|
+
|
|
107
|
+
expect(optionsWrapper.exists()).toBeTruthy();
|
|
108
|
+
expect(optionsWrapper.isVisible()).toBeTruthy();
|
|
109
|
+
|
|
110
|
+
done();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
it("correctly handles 'disabled' prop value", async () => {
|
|
116
|
+
const propsData = {
|
|
117
|
+
disabled: true,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
121
|
+
|
|
122
|
+
const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput).find("input");
|
|
123
|
+
|
|
124
|
+
expect(inputWrapper.attributes("disabled")).toBeDefined();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
it("correctly handles 'highlightOptions' prop value", async () => {
|
|
129
|
+
const propsData = {
|
|
130
|
+
defaultExpanded: true,
|
|
131
|
+
themeType: "teal",
|
|
132
|
+
options: globalThis.OPTIONS,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
136
|
+
|
|
137
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
138
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
139
|
+
const optionElement = optionsListWrapper.find("[role=option]");
|
|
140
|
+
|
|
141
|
+
await fireEvent.mouseOver(optionElement.element);
|
|
142
|
+
|
|
143
|
+
expect(optionElement.classes()).toContain("extended__multiselect-options_option-teal");
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
it("correctly handles 'loading' prop value", async () => {
|
|
148
|
+
const propsData = {
|
|
149
|
+
loading: true,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
153
|
+
|
|
154
|
+
const loaderWrapper = wrapper.findComponent(ExtendedMultiselectLoader);
|
|
155
|
+
|
|
156
|
+
expect(loaderWrapper.exists()).toBeTruthy();
|
|
157
|
+
expect(loaderWrapper.isVisible()).toBeTruthy();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
it("correctly handles 'multiple' prop value", async () => {
|
|
162
|
+
const propsData = {
|
|
163
|
+
defaultExpanded: true,
|
|
164
|
+
multiple: true,
|
|
165
|
+
options: globalThis.OPTIONS,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
169
|
+
|
|
170
|
+
const toggleWrapper = wrapper.find("#extended__multiselect-toggle");
|
|
171
|
+
|
|
172
|
+
await mockOptionSelection(wrapper);
|
|
173
|
+
await fireEvent.click(toggleWrapper.element);
|
|
174
|
+
await mockOptionSelection(wrapper);
|
|
175
|
+
|
|
176
|
+
const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple");
|
|
177
|
+
|
|
178
|
+
expect(multipleWrapper.text()).toMatch(globalThis.OPTIONS[0].label);
|
|
179
|
+
expect(multipleWrapper.text()).toMatch(globalThis.OPTIONS[1].label);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
it("correctly handles 'noResultsBlockShown' prop value", async () => {
|
|
184
|
+
const propsData = {
|
|
185
|
+
defaultExpanded: true,
|
|
186
|
+
options: globalThis.OPTIONS,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
wrapper = await mountComponent(
|
|
190
|
+
Vue3ExtendedMultiselect,
|
|
191
|
+
false,
|
|
192
|
+
propsData,
|
|
193
|
+
wrapperProvides(globalThis.SEARCH_VALUE, NO_OPTIONS_PATTERN ),
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
expect(wrapper.text()).toMatch("No results were found by search");
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
it("correctly handles 'resetSearchByValue' prop value", async () => {
|
|
201
|
+
const propsData = {
|
|
202
|
+
defaultExpanded: true,
|
|
203
|
+
options: globalThis.OPTIONS,
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
207
|
+
|
|
208
|
+
const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput).find("input");
|
|
209
|
+
|
|
210
|
+
await inputWrapper.setValue("Value");
|
|
211
|
+
await mockOptionSelection(wrapper);
|
|
212
|
+
|
|
213
|
+
expect(inputWrapper.element.value).toHaveLength(0);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
it("correctly handles 'searchFilterActive' prop value", async () => {
|
|
218
|
+
const propsData = {
|
|
219
|
+
defaultExpanded: true,
|
|
220
|
+
options: globalThis.OPTIONS,
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
wrapper = await mountComponent(
|
|
224
|
+
Vue3ExtendedMultiselect,
|
|
225
|
+
false,
|
|
226
|
+
propsData,
|
|
227
|
+
wrapperProvides(globalThis.SEARCH_VALUE, FIRST_OPTION_PATTERN),
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
231
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
232
|
+
|
|
233
|
+
expect(optionsListWrapper.element.children).toHaveLength(1);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
it("correctly handles 'simpleEvents' prop value", async () => {
|
|
238
|
+
const propsData = {
|
|
239
|
+
defaultExpanded: true,
|
|
240
|
+
inputId: globalThis.INPUT_ID,
|
|
241
|
+
options: globalThis.OPTIONS,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
245
|
+
|
|
246
|
+
await mockOptionSelection(wrapper);
|
|
247
|
+
|
|
248
|
+
expect(wrapper.emitted().select[0][0].label).toEqual(globalThis.OPTIONS[0].label);
|
|
249
|
+
|
|
250
|
+
propsData.simpleEvents = false;
|
|
251
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
252
|
+
|
|
253
|
+
await mockOptionSelection(wrapper);
|
|
254
|
+
|
|
255
|
+
expect(wrapper.emitted().select[0][0].inputId).toEqual(globalThis.INPUT_ID);
|
|
256
|
+
expect(wrapper.emitted().select[0][0].option.label).toEqual(globalThis.OPTIONS[0].label);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
it("correctly handles 'selectedOptionsShown' prop value", async () => {
|
|
261
|
+
const propsData = {
|
|
262
|
+
defaultExpanded: true,
|
|
263
|
+
selectedOptionsShown: true,
|
|
264
|
+
options: globalThis.OPTIONS,
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
268
|
+
|
|
269
|
+
await mockOptionSelection(wrapper);
|
|
270
|
+
await expandOptionsList(wrapper);
|
|
271
|
+
|
|
272
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
273
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
274
|
+
|
|
275
|
+
expect(optionsListWrapper.element.children).toHaveLength(3);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
it("correctly handles 'showClearIcon' prop value", async () => {
|
|
280
|
+
const propsData = {
|
|
281
|
+
showClearIcon: true,
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
285
|
+
|
|
286
|
+
const cancelWrapper = wrapper.find("#extended__multiselect-cancel");
|
|
287
|
+
|
|
288
|
+
expect(cancelWrapper.exists()).toBeTruthy();
|
|
289
|
+
expect(cancelWrapper.isVisible()).toBeTruthy();
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
it("correctly handles 'showInsertWarnings' prop value", async () => {
|
|
294
|
+
const propsData = {
|
|
295
|
+
defaultExpanded: true,
|
|
296
|
+
showInsertWarnings: true,
|
|
297
|
+
options: [{ label: { noLabel: "Wrong option" }}],
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
console.warn = (warning) => {
|
|
301
|
+
globalThis.warning = warning;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
305
|
+
|
|
306
|
+
expect(globalThis.warning).toEqual("vue-extended-multiselect: «label» property can not be of type «object»");
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
it("correctly handles 'showMarker' prop value", async () => {
|
|
311
|
+
const propsData = {
|
|
312
|
+
defaultExpanded: true,
|
|
313
|
+
selectedOptionsShown: true,
|
|
314
|
+
showMarker: true,
|
|
315
|
+
options: globalThis.OPTIONS,
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
319
|
+
|
|
320
|
+
await mockOptionSelection(wrapper);
|
|
321
|
+
await expandOptionsList(wrapper);
|
|
322
|
+
|
|
323
|
+
const markerWrapper = wrapper.find(".extended__multiselect-marker");
|
|
324
|
+
|
|
325
|
+
expect(markerWrapper.exists()).toBeTruthy();
|
|
326
|
+
expect(markerWrapper.isVisible()).toBeTruthy();
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
it("correctly handles 'showSearchField' prop value", async () => {
|
|
331
|
+
const propsData = {
|
|
332
|
+
defaultExpanded: true,
|
|
333
|
+
inputId: globalThis.INPUT_ID,
|
|
334
|
+
options: globalThis.OPTIONS,
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
338
|
+
|
|
339
|
+
let inputWrapper = wrapper.find("input");
|
|
340
|
+
|
|
341
|
+
expect(inputWrapper.attributes("id")).toEqual(globalThis.INPUT_ID);
|
|
342
|
+
|
|
343
|
+
propsData.showSearchField = false;
|
|
344
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
345
|
+
|
|
346
|
+
await mockOptionSelection(wrapper);
|
|
347
|
+
|
|
348
|
+
inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
|
|
349
|
+
|
|
350
|
+
const selectedOptionWrapper = inputWrapper.find(".extended__multiselect-block");
|
|
351
|
+
expect(selectedOptionWrapper.text()).toMatch("First Option");
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
it("correctly handles 'toggleMultipleBlocksLimit' prop value", async () => {
|
|
356
|
+
const propsData = {
|
|
357
|
+
defaultExpanded: true,
|
|
358
|
+
multiple: true,
|
|
359
|
+
toggleMultipleBlocksLimit: true,
|
|
360
|
+
multipleBlocksLimit: 1,
|
|
361
|
+
options: globalThis.OPTIONS,
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
365
|
+
|
|
366
|
+
await mockOptionSelection(wrapper);
|
|
367
|
+
await expandOptionsList(wrapper);
|
|
368
|
+
await mockOptionSelection(wrapper);
|
|
369
|
+
|
|
370
|
+
const increaserWrapper = wrapper.find(".extended__multiselect-increaser");
|
|
371
|
+
|
|
372
|
+
expect(increaserWrapper.exists()).toBeTruthy();
|
|
373
|
+
expect(increaserWrapper.isVisible()).toBeTruthy();
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
it("correctly handles 'toggleOptionsBySelect' prop value", async () => {
|
|
378
|
+
const propsData = {
|
|
379
|
+
defaultExpanded: true,
|
|
380
|
+
options: globalThis.OPTIONS,
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
384
|
+
|
|
385
|
+
await mockOptionSelection(wrapper);
|
|
386
|
+
|
|
387
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
388
|
+
|
|
389
|
+
expect(optionsWrapper.exists()).toBeFalsy();
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
it("correctly handles 'togglingSavesSearchValue' prop value", async () => {
|
|
394
|
+
const propsData = {
|
|
395
|
+
defaultExpanded: true,
|
|
396
|
+
options: globalThis.OPTIONS,
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
400
|
+
|
|
401
|
+
let toggleWrapper = wrapper.find("#extended__multiselect-toggle");
|
|
402
|
+
let inputWrapper = wrapper.find("input");
|
|
403
|
+
|
|
404
|
+
await inputWrapper.setValue(globalThis.SEARCH_VALUE);
|
|
405
|
+
await fireEvent.click(toggleWrapper.element);
|
|
406
|
+
|
|
407
|
+
expect(inputWrapper.element.value).toEqual(globalThis.SEARCH_VALUE);
|
|
408
|
+
|
|
409
|
+
propsData.togglingSavesSearchValue = false;
|
|
410
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
411
|
+
toggleWrapper = wrapper.find("#extended__multiselect-toggle");
|
|
412
|
+
inputWrapper = wrapper.find("input");
|
|
413
|
+
|
|
414
|
+
await inputWrapper.setValue(globalThis.SEARCH_VALUE);
|
|
415
|
+
await fireEvent.click(toggleWrapper.element);
|
|
416
|
+
|
|
417
|
+
expect(inputWrapper.element.value).toHaveLength(0);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
it("correctly handles 'wrongCurrentValue' prop value", async () => {
|
|
422
|
+
const propsData = {
|
|
423
|
+
wrongCurrentValue: true,
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData).find("#extended__multiselect");
|
|
427
|
+
|
|
428
|
+
expect(wrapper.attributes("style")).toMatch("border-color: #ff0000");
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
it("correctly handles 'createOptionPlaceholder' prop value", async () => {
|
|
433
|
+
const propsData = {
|
|
434
|
+
createOnTheGo: true,
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
438
|
+
|
|
439
|
+
const inputWrapper = wrapper.find("input");
|
|
440
|
+
|
|
441
|
+
expect(inputWrapper.attributes("placeholder")).toEqual("Select or create features");
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
it("correctly handles 'createOptionType' prop value", async () => {
|
|
446
|
+
const propsData = {
|
|
447
|
+
autoSelectCreatedOption: true,
|
|
448
|
+
createOnTheGo: true,
|
|
449
|
+
defaultExpanded: true,
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
wrapper = await mountComponent(
|
|
453
|
+
Vue3ExtendedMultiselect,
|
|
454
|
+
false,
|
|
455
|
+
propsData,
|
|
456
|
+
wrapperProvides(globalThis.SEARCH_VALUE, SEARCH_PATTERN),
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
await fireEvent.mouseDown(createNewOptionsWrapper(wrapper).element);
|
|
460
|
+
|
|
461
|
+
let inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
|
|
462
|
+
let selectedOption = inputWrapper.find(".extended__multiselect-block").find("span");
|
|
463
|
+
|
|
464
|
+
expect(selectedOption.text()).toEqual(globalThis.SEARCH_VALUE);
|
|
465
|
+
|
|
466
|
+
propsData.createOptionType = "object";
|
|
467
|
+
|
|
468
|
+
wrapper = await mountComponent(
|
|
469
|
+
Vue3ExtendedMultiselect,
|
|
470
|
+
false,
|
|
471
|
+
propsData,
|
|
472
|
+
wrapperProvides(globalThis.SEARCH_VALUE, SEARCH_PATTERN),
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
476
|
+
const createNewOptionsWrapperAfter = optionsWrapper.find("div > div:first-child");
|
|
477
|
+
|
|
478
|
+
await fireEvent.mouseDown(createNewOptionsWrapperAfter.element);
|
|
479
|
+
|
|
480
|
+
inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
|
|
481
|
+
selectedOption = inputWrapper.find(".extended__multiselect-block").find("span");
|
|
482
|
+
|
|
483
|
+
expect(createNewOptionsWrapperAfter.text()).toEqual(globalThis.SEARCH_VALUE);
|
|
484
|
+
expect(wrapper.vm.selectedOptions[0]).toMatchObject({ label: `label-${globalThis.SEARCH_VALUE}` });
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
it("correctly handles 'emptyObjectsPlaceholder' prop value", async () => {
|
|
489
|
+
const propsData = {
|
|
490
|
+
defaultExpanded: true,
|
|
491
|
+
options: [[]],
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
495
|
+
|
|
496
|
+
const selectedOptionWrapper = wrapper.find(".extended__multiselect-block");
|
|
497
|
+
|
|
498
|
+
await mockOptionSelection(wrapper);
|
|
499
|
+
|
|
500
|
+
expect(selectedOptionWrapper.text()).toEqual("Empty Object/Array");
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
it("correctly handles 'errorBorderColor' prop value", async () => {
|
|
505
|
+
const propsData = {
|
|
506
|
+
wrongCurrentValue: true,
|
|
507
|
+
errorBorderColor: "#DC143C",
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData).find("#extended__multiselect");
|
|
511
|
+
|
|
512
|
+
expect(wrapper.attributes("style")).toMatch("border-color: #dc143c");
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
it("correctly handles 'iconFilter' prop value", async () => {
|
|
517
|
+
const propsData = {
|
|
518
|
+
inputId: globalThis.INPUT_ID,
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
522
|
+
|
|
523
|
+
const toggleWrapper = wrapper.find("#extended__multiselect-toggle").find("img");
|
|
524
|
+
|
|
525
|
+
expect(toggleWrapper.classes()).toContain("extended__multiselect-filter_basic");
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
it("correctly handles 'iconSize' prop value", async () => {
|
|
530
|
+
const propsData = {
|
|
531
|
+
inputId: globalThis.INPUT_ID,
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
535
|
+
|
|
536
|
+
const toggleWrapper = wrapper.find("#extended__multiselect-toggle").find("img");
|
|
537
|
+
|
|
538
|
+
expect(toggleWrapper.classes()).toContain("extended__multiselect-toggle_icon-large");
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
it("correctly handles 'label' prop value", async () => {
|
|
543
|
+
const propsData = {
|
|
544
|
+
defaultExpanded: true,
|
|
545
|
+
label: "customLabel",
|
|
546
|
+
options: globalThis.OPTIONS,
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
550
|
+
|
|
551
|
+
const selectedOptionWrapper = wrapper.find(".extended__multiselect-block");
|
|
552
|
+
|
|
553
|
+
await mockOptionSelection(wrapper);
|
|
554
|
+
|
|
555
|
+
expect(selectedOptionWrapper.text()).toEqual(globalThis.OPTIONS[0].customLabel);
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
it("correctly handles 'loaderIconFilter' prop value", async () => {
|
|
560
|
+
const propsData = {
|
|
561
|
+
loading: true,
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
565
|
+
|
|
566
|
+
const loaderWrapper = wrapper.findComponent(ExtendedMultiselectLoader).find("img");
|
|
567
|
+
|
|
568
|
+
expect(loaderWrapper.classes()).toContain("extended__multiselect-loader_default-loader");
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
it("correctly handles 'placeholder' prop value", async () => {
|
|
573
|
+
const propsData = {
|
|
574
|
+
inputId: globalThis.INPUT_ID,
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
578
|
+
|
|
579
|
+
const inputWrapper = wrapper.find("input");
|
|
580
|
+
|
|
581
|
+
expect(inputWrapper.attributes("placeholder")).toEqual("Select features");
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
it("correctly handles 'themeType' prop value", async () => {
|
|
586
|
+
expect.assertions(3);
|
|
587
|
+
|
|
588
|
+
const propsData = {
|
|
589
|
+
defaultExpanded: true,
|
|
590
|
+
multiple: true,
|
|
591
|
+
options: globalThis.OPTIONS,
|
|
592
|
+
preselectedOptions: [globalThis.OPTIONS[0]],
|
|
593
|
+
inputId: globalThis.INPUT_ID,
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
597
|
+
|
|
598
|
+
const multiselectWrapper = wrapper.find("#extended__multiselect");
|
|
599
|
+
const multipleWrapper = wrapper.findComponent(ExtendedMultiselectMultiple);
|
|
600
|
+
const optionWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
601
|
+
|
|
602
|
+
expect(optionWrapper.classes()).toContain("extended__multiselect-options");
|
|
603
|
+
expect(multiselectWrapper.classes()).toContain("extended__multiselect");
|
|
604
|
+
expect(multipleWrapper.find("span").element.parentElement.classList)
|
|
605
|
+
.toContain("extended__multiselect--multiple-basic");
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
it("correctly handles 'toggleAppearanceSide' prop value", async () => {
|
|
610
|
+
const propsData = {
|
|
611
|
+
defaultExpanded: true,
|
|
612
|
+
toggleAppearanceSide: "atop",
|
|
613
|
+
options: globalThis.OPTIONS,
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
617
|
+
|
|
618
|
+
const optionWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
619
|
+
|
|
620
|
+
expect(optionWrapper.attributes("style")).toMatch("top: -0px");
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
it("correctly handles 'toggleIcon' prop value", async () => {
|
|
625
|
+
const propsData = {
|
|
626
|
+
inputId: globalThis.INPUT_ID,
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
630
|
+
|
|
631
|
+
const toggleWrapper = wrapper.findComponent(ExtendedMultiselectToggle);
|
|
632
|
+
const icon = toggleWrapper.find("img");
|
|
633
|
+
|
|
634
|
+
expect(toggleWrapper.props("toggleIcon")).toEqual("double-arrow");
|
|
635
|
+
expect(icon.exists()).toBeTruthy();
|
|
636
|
+
expect(icon.isVisible()).toBeTruthy();
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
it("correctly handles 'anyOptionWrapperBlockHeight' prop value", async () => {
|
|
641
|
+
const propsData = {
|
|
642
|
+
anyOptionWrapperBlockHeight: 50,
|
|
643
|
+
defaultExpanded: true,
|
|
644
|
+
options: globalThis.OPTIONS,
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
648
|
+
|
|
649
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
650
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
651
|
+
const optionElement = optionsListWrapper.find("[role=option]");
|
|
652
|
+
|
|
653
|
+
expect(optionElement.attributes("style")).toMatch("height: 50px");
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
it("correctly handles 'increaseDisplayBy' prop value", async () => {
|
|
658
|
+
const propsData = {
|
|
659
|
+
defaultExpanded: true,
|
|
660
|
+
multiple: true,
|
|
661
|
+
toggleMultipleBlocksLimit: true,
|
|
662
|
+
multipleBlocksLimit: 1,
|
|
663
|
+
options: globalThis.OPTIONS,
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
667
|
+
|
|
668
|
+
await mockOptionSelection(wrapper);
|
|
669
|
+
await expandOptionsList(wrapper);
|
|
670
|
+
await mockOptionSelection(wrapper);
|
|
671
|
+
|
|
672
|
+
const increaserWrapper = wrapper.find(".extended__multiselect-increaser");
|
|
673
|
+
|
|
674
|
+
await fireEvent.click(increaserWrapper.element);
|
|
675
|
+
|
|
676
|
+
const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple");
|
|
677
|
+
|
|
678
|
+
expect(multipleWrapper.element.children).toHaveLength(2);
|
|
679
|
+
expect(multipleWrapper.text()).toMatch(globalThis.OPTIONS[1].label);
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
it("correctly handles 'maxOptionsCount' prop value", async () => {
|
|
684
|
+
const propsData = {
|
|
685
|
+
defaultExpanded: true,
|
|
686
|
+
multiple: true,
|
|
687
|
+
maxOptionsCount: 1,
|
|
688
|
+
options: globalThis.OPTIONS,
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
wrapper = await mountComponent(
|
|
692
|
+
Vue3ExtendedMultiselect,
|
|
693
|
+
false,
|
|
694
|
+
propsData,
|
|
695
|
+
wrapperSlots,
|
|
696
|
+
);
|
|
697
|
+
|
|
698
|
+
await mockOptionSelection(wrapper);
|
|
699
|
+
await expandOptionsList(wrapper);
|
|
700
|
+
await mockOptionSelection(wrapper);
|
|
701
|
+
|
|
702
|
+
const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple");
|
|
703
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
704
|
+
|
|
705
|
+
expect(multipleWrapper.element.children).toHaveLength(1);
|
|
706
|
+
expect(optionsWrapper.text()).toMatch(globalThis.MORE_THAN_LIMIT);
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
it("correctly handles 'minOptionsCount' prop value", async () => {
|
|
711
|
+
const propsData = {
|
|
712
|
+
defaultExpanded: true,
|
|
713
|
+
multiple: true,
|
|
714
|
+
minOptionsCount: 2,
|
|
715
|
+
options: globalThis.OPTIONS,
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
wrapper = await mountComponent(
|
|
719
|
+
Vue3ExtendedMultiselect,
|
|
720
|
+
false,
|
|
721
|
+
propsData,
|
|
722
|
+
wrapperSlots,
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
let optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
726
|
+
|
|
727
|
+
expect(optionsWrapper.text()).toMatch(globalThis.LESS_THAN_LIMIT);
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
it("correctly handles 'multipleBlocksLimit' prop value", async () => {
|
|
732
|
+
const propsData = {
|
|
733
|
+
defaultExpanded: true,
|
|
734
|
+
multiple: true,
|
|
735
|
+
multipleBlocksLimit: 1,
|
|
736
|
+
options: globalThis.OPTIONS,
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
740
|
+
|
|
741
|
+
await mockOptionSelection(wrapper);
|
|
742
|
+
await expandOptionsList(wrapper);
|
|
743
|
+
await mockOptionSelection(wrapper);
|
|
744
|
+
|
|
745
|
+
const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple");
|
|
746
|
+
|
|
747
|
+
expect(multipleWrapper.text()).toMatch("and 1 more items");
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
it("correctly handles 'optionsCountRestriction' prop value", async () => {
|
|
752
|
+
const propsData = {
|
|
753
|
+
defaultExpanded: true,
|
|
754
|
+
multiple: true,
|
|
755
|
+
optionsCountRestriction: 1,
|
|
756
|
+
options: globalThis.OPTIONS,
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
760
|
+
|
|
761
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
762
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
763
|
+
|
|
764
|
+
expect(optionsListWrapper.element.children).toHaveLength(1);
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
it("correctly handles 'toggleMaxHeight' prop value", async () => {
|
|
769
|
+
const propsData = {
|
|
770
|
+
defaultExpanded: true,
|
|
771
|
+
toggleMaxHeight: 100,
|
|
772
|
+
options: globalThis.OPTIONS,
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
776
|
+
|
|
777
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
778
|
+
|
|
779
|
+
expect(optionsWrapper.attributes("style")).toMatch("max-height: 100px");
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
it("correctly handles 'toggleMinHeight' prop value", async () => {
|
|
784
|
+
const propsData = {
|
|
785
|
+
defaultExpanded: true,
|
|
786
|
+
toggleMinHeight: 50,
|
|
787
|
+
options: globalThis.OPTIONS,
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
791
|
+
|
|
792
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
793
|
+
|
|
794
|
+
expect(optionsWrapper.attributes("style")).toMatch("min-height: 50px");
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
it("correctly handles 'createOptionFields' prop value", async () => {
|
|
799
|
+
const propsData = {
|
|
800
|
+
autoSelectCreatedOption: true,
|
|
801
|
+
createOnTheGo: true,
|
|
802
|
+
createOptionType: "object",
|
|
803
|
+
createOptionFields: ["label", "id"],
|
|
804
|
+
defaultExpanded: true,
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
const createdOption = {
|
|
808
|
+
label: "label-Search for options",
|
|
809
|
+
id: "id-Search for options",
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
wrapper = await mountComponent(
|
|
813
|
+
Vue3ExtendedMultiselect,
|
|
814
|
+
false,
|
|
815
|
+
propsData,
|
|
816
|
+
wrapperProvides(globalThis.SEARCH_VALUE, SEARCH_PATTERN),
|
|
817
|
+
);
|
|
818
|
+
|
|
819
|
+
await fireEvent.mouseDown(createNewOptionsWrapper(wrapper).element);
|
|
820
|
+
|
|
821
|
+
expect(wrapper.vm.selectedOptions[0]).toEqual(createdOption);
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
it("correctly handles 'disabledPrimitiveOptions' prop value", async () => {
|
|
826
|
+
const propsData = {
|
|
827
|
+
defaultExpanded: true,
|
|
828
|
+
disabledPrimitiveOptions: [126],
|
|
829
|
+
options: globalThis.OPTIONS,
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
833
|
+
|
|
834
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
835
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
836
|
+
const optionElement = optionsListWrapper.findAll(".extended__multiselect-options_option").at(2);
|
|
837
|
+
|
|
838
|
+
expect(optionElement.classes()).toContain("extended__multiselect-options_option--disabled");
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
it("correctly handles 'options' prop value", async (done) => {
|
|
843
|
+
expect.assertions(2);
|
|
844
|
+
|
|
845
|
+
const propsData = {
|
|
846
|
+
defaultExpanded: true,
|
|
847
|
+
options: globalThis.OPTIONS,
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
851
|
+
|
|
852
|
+
let optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
853
|
+
let optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
854
|
+
|
|
855
|
+
expect(optionsListWrapper.element.children).toHaveLength(3);
|
|
856
|
+
|
|
857
|
+
const optionsLoader = async () => {
|
|
858
|
+
return await Promise.resolve(globalThis.OPTIONS);
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
propsData.options = optionsLoader;
|
|
862
|
+
|
|
863
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
864
|
+
|
|
865
|
+
process.nextTick(async () => {
|
|
866
|
+
expect(wrapper.vm.rawOptions).toHaveLength(3);
|
|
867
|
+
done();
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
it("correctly handles 'optionsPadding' prop value", async () => {
|
|
873
|
+
const propsData = {
|
|
874
|
+
defaultExpanded: true,
|
|
875
|
+
optionsPadding: [5, 10, 10, 5],
|
|
876
|
+
options: globalThis.OPTIONS,
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
880
|
+
|
|
881
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
882
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
883
|
+
const optionElement = optionsListWrapper.find(".extended__multiselect-options_option");
|
|
884
|
+
|
|
885
|
+
expect(optionElement.attributes("style")).toMatch("5px 5px 10px 10px");
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
it("correctly handles 'preselectedOptions' prop value", async () => {
|
|
890
|
+
expect.assertions(1);
|
|
891
|
+
|
|
892
|
+
const propsData = {
|
|
893
|
+
defaultExpanded: true,
|
|
894
|
+
multiple: true,
|
|
895
|
+
preselectedOptions: [globalThis.OPTIONS[0], globalThis.OPTIONS[1]],
|
|
896
|
+
options: globalThis.OPTIONS,
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
900
|
+
|
|
901
|
+
const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple");
|
|
902
|
+
|
|
903
|
+
expect(multipleWrapper.element.children).toHaveLength(2);
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
it("correctly handles 'specialKeysBlock' prop value", async () => {
|
|
908
|
+
const propsData = {
|
|
909
|
+
defaultExpanded: true,
|
|
910
|
+
specialKeysBlock: ["alt"],
|
|
911
|
+
options: globalThis.OPTIONS,
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
915
|
+
|
|
916
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
917
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
918
|
+
const optionElement = optionsListWrapper.find(".extended__multiselect-options_option");
|
|
919
|
+
const selectedOptionWrapper = wrapper.find(".extended__multiselect-block");
|
|
920
|
+
|
|
921
|
+
await fireEvent.mouseOver(optionElement.element);
|
|
922
|
+
await fireEvent.keyPress(optionElement.element, {
|
|
923
|
+
key: "Enter",
|
|
924
|
+
altKey: true,
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
expect(selectedOptionWrapper.text()).toHaveLength(0);
|
|
928
|
+
|
|
929
|
+
await fireEvent.keyPress(optionElement.element, {
|
|
930
|
+
key: "Enter",
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
expect(selectedOptionWrapper.text()).toEqual(globalThis.OPTIONS[0].label);
|
|
934
|
+
});
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
it("correctly handles v-model", async () => {
|
|
938
|
+
const ApplicationToUse = {
|
|
939
|
+
name: "ApplicationToUse",
|
|
940
|
+
|
|
941
|
+
template:
|
|
942
|
+
`<div>
|
|
943
|
+
<vue3-extended-multiselect
|
|
944
|
+
default-expanded
|
|
945
|
+
v-model="value"
|
|
946
|
+
:options="['Test Option']"
|
|
947
|
+
/>
|
|
948
|
+
</div>`,
|
|
949
|
+
|
|
950
|
+
components: {
|
|
951
|
+
Vue3ExtendedMultiselect,
|
|
952
|
+
},
|
|
953
|
+
|
|
954
|
+
data() {
|
|
955
|
+
return { value: null };
|
|
956
|
+
},
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
const application = await mountComponent(ApplicationToUse);
|
|
960
|
+
const multiselectWrapper = application.findComponent(Vue3ExtendedMultiselect);
|
|
961
|
+
|
|
962
|
+
await mockOptionSelection(multiselectWrapper);
|
|
963
|
+
|
|
964
|
+
expect(application.vm.value).toEqual("Test Option");
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
it("correctly handles 'createCustomOptionLabel' prop value", async () => {
|
|
969
|
+
const propsData = {
|
|
970
|
+
createCustomOptionLabel: (option) => `test-${option.label}`,
|
|
971
|
+
defaultExpanded: true,
|
|
972
|
+
options: globalThis.OPTIONS,
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
976
|
+
|
|
977
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
978
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
979
|
+
const optionElement = optionsListWrapper.find(".extended__multiselect-options_option");
|
|
980
|
+
|
|
981
|
+
expect(optionElement.text()).toMatch("test-First Option");
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
it("correctly handles 'multipleBlocksLimitMessage' prop value", async () => {
|
|
986
|
+
expect.assertions(1);
|
|
987
|
+
|
|
988
|
+
const propsData = {
|
|
989
|
+
multiple: true,
|
|
990
|
+
multipleBlocksLimit: 1,
|
|
991
|
+
multipleBlocksLimitMessage: (amount) => `${amount} more items below`,
|
|
992
|
+
preselectedOptions: [globalThis.OPTIONS[0], globalThis.OPTIONS[1]],
|
|
993
|
+
options: globalThis.OPTIONS,
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
997
|
+
|
|
998
|
+
const multipleWrapper = wrapper.findComponent(ExtendedMultiselectMultiple);
|
|
999
|
+
|
|
1000
|
+
expect(multipleWrapper.text()).toMatch("1 more items below");
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
it("correctly handles 'inputId' prop value", async () => {
|
|
1005
|
+
const propsData = {
|
|
1006
|
+
inputId: globalThis.INPUT_ID,
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
1010
|
+
|
|
1011
|
+
const inputWrapper = wrapper.find("input");
|
|
1012
|
+
|
|
1013
|
+
expect(inputWrapper.attributes("id")).toEqual(globalThis.INPUT_ID);
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
it("correctly handles 'preselectedOption' prop value", async (done) => {
|
|
1018
|
+
expect.assertions(2);
|
|
1019
|
+
|
|
1020
|
+
const propsData = {
|
|
1021
|
+
preselectedOption: globalThis.OPTIONS[0],
|
|
1022
|
+
options: globalThis.OPTIONS,
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
1026
|
+
|
|
1027
|
+
process.nextTick(async () => {
|
|
1028
|
+
await expandOptionsList(wrapper);
|
|
1029
|
+
|
|
1030
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
1031
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
1032
|
+
const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
|
|
1033
|
+
const selectedOption = inputWrapper.find(".extended__multiselect-block").find("span");
|
|
1034
|
+
|
|
1035
|
+
expect(optionsListWrapper.element.children).toHaveLength(2);
|
|
1036
|
+
expect(selectedOption.text()).toEqual(globalThis.OPTIONS[0].label);
|
|
1037
|
+
|
|
1038
|
+
done();
|
|
1039
|
+
});
|
|
1040
|
+
});
|
|
1041
|
+
});
|