vue-instantsearch 4.10.5 → 4.10.6
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/package.json +4 -4
- package/src/__tests__/common-connectors.test.js +359 -0
- package/src/__tests__/common-shared.test.js +93 -0
- package/src/__tests__/common-widgets.test.js +343 -0
- package/vue2/cjs/index.js +1 -1
- package/vue2/es/package.json.js +1 -1
- package/vue2/umd/index.js +1 -1
- package/vue2/umd/index.js.map +1 -1
- package/vue3/cjs/index.js +1 -1
- package/vue3/es/package.json.js +1 -1
- package/vue3/umd/index.js +1 -1
- package/vue3/umd/index.js.map +1 -1
- package/src/__tests__/common.test.js +0 -586
|
@@ -1,586 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
createRefinementListTests,
|
|
6
|
-
createHierarchicalMenuTests,
|
|
7
|
-
createBreadcrumbTests,
|
|
8
|
-
createMenuTests,
|
|
9
|
-
createPaginationTests,
|
|
10
|
-
createInfiniteHitsTests,
|
|
11
|
-
createHitsTests,
|
|
12
|
-
createRangeInputTests,
|
|
13
|
-
createInstantSearchTests,
|
|
14
|
-
createCurrentRefinementsTests,
|
|
15
|
-
createHitsPerPageTests,
|
|
16
|
-
createNumericMenuTests,
|
|
17
|
-
createRatingMenuTests,
|
|
18
|
-
createToggleRefinementTests,
|
|
19
|
-
createSharedTests,
|
|
20
|
-
} from '@instantsearch/tests';
|
|
21
|
-
|
|
22
|
-
import { nextTick, mountApp } from '../../test/utils';
|
|
23
|
-
import { renderCompat } from '../util/vue-compat';
|
|
24
|
-
import {
|
|
25
|
-
AisInstantSearch,
|
|
26
|
-
AisRefinementList,
|
|
27
|
-
AisHierarchicalMenu,
|
|
28
|
-
AisBreadcrumb,
|
|
29
|
-
AisMenu,
|
|
30
|
-
AisPagination,
|
|
31
|
-
AisInfiniteHits,
|
|
32
|
-
AisSearchBox,
|
|
33
|
-
createWidgetMixin,
|
|
34
|
-
AisHits,
|
|
35
|
-
AisIndex,
|
|
36
|
-
AisRangeInput,
|
|
37
|
-
AisCurrentRefinements,
|
|
38
|
-
AisHitsPerPage,
|
|
39
|
-
AisNumericMenu,
|
|
40
|
-
AisRatingMenu,
|
|
41
|
-
AisToggleRefinement,
|
|
42
|
-
} from '../instantsearch';
|
|
43
|
-
import {
|
|
44
|
-
connectBreadcrumb,
|
|
45
|
-
connectCurrentRefinements,
|
|
46
|
-
connectHierarchicalMenu,
|
|
47
|
-
connectHitsPerPage,
|
|
48
|
-
connectMenu,
|
|
49
|
-
connectNumericMenu,
|
|
50
|
-
connectPagination,
|
|
51
|
-
connectRatingMenu,
|
|
52
|
-
connectRefinementList,
|
|
53
|
-
connectToggleRefinement,
|
|
54
|
-
} from 'instantsearch.js/es/connectors';
|
|
55
|
-
jest.unmock('instantsearch.js/es');
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* prevent rethrowing InstantSearch errors, so tests can be asserted.
|
|
59
|
-
* IRL this isn't needed, as the error doesn't stop execution.
|
|
60
|
-
*/
|
|
61
|
-
const GlobalErrorSwallower = {
|
|
62
|
-
mixins: [createWidgetMixin({ connector: true })],
|
|
63
|
-
mounted() {
|
|
64
|
-
this.instantSearchInstance.on('error', () => {});
|
|
65
|
-
},
|
|
66
|
-
render() {
|
|
67
|
-
return null;
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
createRefinementListTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
72
|
-
const RefinementListURL = createURLComponent({
|
|
73
|
-
connector: connectRefinementList,
|
|
74
|
-
name: 'RefinementList',
|
|
75
|
-
requiredProps: ['attribute'],
|
|
76
|
-
urlValue: 'value',
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
mountApp(
|
|
80
|
-
{
|
|
81
|
-
render: renderCompat((h) =>
|
|
82
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
83
|
-
h(RefinementListURL, { props: widgetParams }),
|
|
84
|
-
h(AisRefinementList, { props: widgetParams }),
|
|
85
|
-
h(GlobalErrorSwallower),
|
|
86
|
-
])
|
|
87
|
-
),
|
|
88
|
-
},
|
|
89
|
-
document.body.appendChild(document.createElement('div'))
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
await nextTick();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
createHierarchicalMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
96
|
-
const HierarchicalMenuURL = createURLComponent({
|
|
97
|
-
connector: connectHierarchicalMenu,
|
|
98
|
-
name: 'HierarchicalMenu',
|
|
99
|
-
requiredProps: ['attributes'],
|
|
100
|
-
urlValue: 'value',
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
mountApp(
|
|
104
|
-
{
|
|
105
|
-
render: renderCompat((h) =>
|
|
106
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
107
|
-
h(HierarchicalMenuURL, { props: widgetParams }),
|
|
108
|
-
h(AisHierarchicalMenu, { props: widgetParams }),
|
|
109
|
-
h(GlobalErrorSwallower),
|
|
110
|
-
])
|
|
111
|
-
),
|
|
112
|
-
},
|
|
113
|
-
document.body.appendChild(document.createElement('div'))
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
await nextTick();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
createBreadcrumbTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
120
|
-
// The passed `transformItems` prop is meant to apply only to the breadcrumb,
|
|
121
|
-
// not the hierarchical menu
|
|
122
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
123
|
-
const { transformItems, ...hierarchicalWidgetParams } = widgetParams;
|
|
124
|
-
|
|
125
|
-
const BreadcrumbURL = createURLComponent({
|
|
126
|
-
connector: connectBreadcrumb,
|
|
127
|
-
name: 'Breadcrumb',
|
|
128
|
-
requiredProps: ['attributes'],
|
|
129
|
-
urlValue: 'Apple > iPhone',
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
mountApp(
|
|
133
|
-
{
|
|
134
|
-
render: renderCompat((h) =>
|
|
135
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
136
|
-
h(BreadcrumbURL, { props: widgetParams }),
|
|
137
|
-
h(AisBreadcrumb, { props: widgetParams }),
|
|
138
|
-
h(AisHierarchicalMenu, { props: hierarchicalWidgetParams }),
|
|
139
|
-
h(GlobalErrorSwallower),
|
|
140
|
-
])
|
|
141
|
-
),
|
|
142
|
-
},
|
|
143
|
-
document.body.appendChild(document.createElement('div'))
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
await nextTick();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
createMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
150
|
-
const MenuURL = createURLComponent({
|
|
151
|
-
connector: connectMenu,
|
|
152
|
-
name: 'Menu',
|
|
153
|
-
requiredProps: ['attribute'],
|
|
154
|
-
urlValue: 'value',
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
mountApp(
|
|
158
|
-
{
|
|
159
|
-
render: renderCompat((h) =>
|
|
160
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
161
|
-
h(MenuURL, { props: widgetParams }),
|
|
162
|
-
h(AisMenu, { props: widgetParams }),
|
|
163
|
-
h(GlobalErrorSwallower),
|
|
164
|
-
])
|
|
165
|
-
),
|
|
166
|
-
},
|
|
167
|
-
document.body.appendChild(document.createElement('div'))
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
await nextTick();
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
createPaginationTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
174
|
-
const PaginationURL = createURLComponent({
|
|
175
|
-
connector: connectPagination,
|
|
176
|
-
name: 'Pagination',
|
|
177
|
-
urlValue: 10,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
mountApp(
|
|
181
|
-
{
|
|
182
|
-
render: renderCompat((h) =>
|
|
183
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
184
|
-
h(PaginationURL, { props: widgetParams }),
|
|
185
|
-
h(AisPagination, { props: widgetParams }),
|
|
186
|
-
h(GlobalErrorSwallower),
|
|
187
|
-
])
|
|
188
|
-
),
|
|
189
|
-
},
|
|
190
|
-
document.body.appendChild(document.createElement('div'))
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
await nextTick();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
createInfiniteHitsTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
197
|
-
mountApp(
|
|
198
|
-
{
|
|
199
|
-
render: renderCompat((h) =>
|
|
200
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
201
|
-
h(AisSearchBox),
|
|
202
|
-
h(AisInfiniteHits, {
|
|
203
|
-
attrs: { id: 'main-hits' },
|
|
204
|
-
props: widgetParams,
|
|
205
|
-
scopedSlots: {
|
|
206
|
-
item: ({ item: hit, sendEvent }) =>
|
|
207
|
-
h(
|
|
208
|
-
'div',
|
|
209
|
-
{
|
|
210
|
-
attrs: {
|
|
211
|
-
'data-testid': `main-hits-top-level-${hit.__position}`,
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
[
|
|
215
|
-
hit.objectID,
|
|
216
|
-
h('button', {
|
|
217
|
-
attrs: {
|
|
218
|
-
'data-testid': `main-hits-convert-${hit.__position}`,
|
|
219
|
-
},
|
|
220
|
-
on: {
|
|
221
|
-
click: () => sendEvent('conversion', hit, 'Converted'),
|
|
222
|
-
},
|
|
223
|
-
}),
|
|
224
|
-
h('button', {
|
|
225
|
-
attrs: {
|
|
226
|
-
'data-testid': `main-hits-click-${hit.__position}`,
|
|
227
|
-
},
|
|
228
|
-
on: {
|
|
229
|
-
click: () => sendEvent('click', hit, 'Clicked'),
|
|
230
|
-
},
|
|
231
|
-
}),
|
|
232
|
-
]
|
|
233
|
-
),
|
|
234
|
-
},
|
|
235
|
-
}),
|
|
236
|
-
h(AisIndex, { props: { indexName: 'nested' } }, [
|
|
237
|
-
h(AisInfiniteHits, {
|
|
238
|
-
attrs: { id: 'nested-hits' },
|
|
239
|
-
scopedSlots: {
|
|
240
|
-
item: ({ item: hit, sendEvent }) =>
|
|
241
|
-
h(
|
|
242
|
-
'div',
|
|
243
|
-
{
|
|
244
|
-
attrs: {
|
|
245
|
-
'data-testid': `nested-hits-top-level-${hit.__position}`,
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
[
|
|
249
|
-
hit.objectID,
|
|
250
|
-
h('button', {
|
|
251
|
-
attrs: {
|
|
252
|
-
'data-testid': `nested-hits-click-${hit.__position}`,
|
|
253
|
-
},
|
|
254
|
-
on: {
|
|
255
|
-
click: () =>
|
|
256
|
-
sendEvent('click', hit, 'Clicked nested'),
|
|
257
|
-
},
|
|
258
|
-
}),
|
|
259
|
-
]
|
|
260
|
-
),
|
|
261
|
-
},
|
|
262
|
-
}),
|
|
263
|
-
]),
|
|
264
|
-
h(GlobalErrorSwallower),
|
|
265
|
-
])
|
|
266
|
-
),
|
|
267
|
-
},
|
|
268
|
-
document.body.appendChild(document.createElement('div'))
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
await nextTick();
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
createHitsTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
275
|
-
mountApp(
|
|
276
|
-
{
|
|
277
|
-
render: renderCompat((h) =>
|
|
278
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
279
|
-
h(AisSearchBox),
|
|
280
|
-
h(AisHits, {
|
|
281
|
-
attrs: { id: 'main-hits' },
|
|
282
|
-
props: widgetParams,
|
|
283
|
-
scopedSlots: {
|
|
284
|
-
item: ({ item: hit, sendEvent }) =>
|
|
285
|
-
h(
|
|
286
|
-
'div',
|
|
287
|
-
{
|
|
288
|
-
attrs: {
|
|
289
|
-
'data-testid': `main-hits-top-level-${hit.__position}`,
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
[
|
|
293
|
-
hit.objectID,
|
|
294
|
-
h('button', {
|
|
295
|
-
attrs: {
|
|
296
|
-
'data-testid': `main-hits-convert-${hit.__position}`,
|
|
297
|
-
},
|
|
298
|
-
on: {
|
|
299
|
-
click: () => sendEvent('conversion', hit, 'Converted'),
|
|
300
|
-
},
|
|
301
|
-
}),
|
|
302
|
-
h('button', {
|
|
303
|
-
attrs: {
|
|
304
|
-
'data-testid': `main-hits-click-${hit.__position}`,
|
|
305
|
-
},
|
|
306
|
-
on: {
|
|
307
|
-
click: () => sendEvent('click', hit, 'Clicked'),
|
|
308
|
-
},
|
|
309
|
-
}),
|
|
310
|
-
]
|
|
311
|
-
),
|
|
312
|
-
},
|
|
313
|
-
}),
|
|
314
|
-
h(AisIndex, { props: { indexName: 'nested' } }, [
|
|
315
|
-
h(AisHits, {
|
|
316
|
-
attrs: { id: 'nested-hits' },
|
|
317
|
-
scopedSlots: {
|
|
318
|
-
item: ({ item: hit, sendEvent }) =>
|
|
319
|
-
h(
|
|
320
|
-
'div',
|
|
321
|
-
{
|
|
322
|
-
attrs: {
|
|
323
|
-
'data-testid': `nested-hits-top-level-${hit.__position}`,
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
[
|
|
327
|
-
hit.objectID,
|
|
328
|
-
h('button', {
|
|
329
|
-
attrs: {
|
|
330
|
-
'data-testid': `nested-hits-click-${hit.__position}`,
|
|
331
|
-
},
|
|
332
|
-
on: {
|
|
333
|
-
click: () =>
|
|
334
|
-
sendEvent('click', hit, 'Clicked nested'),
|
|
335
|
-
},
|
|
336
|
-
}),
|
|
337
|
-
]
|
|
338
|
-
),
|
|
339
|
-
},
|
|
340
|
-
}),
|
|
341
|
-
]),
|
|
342
|
-
h(GlobalErrorSwallower),
|
|
343
|
-
])
|
|
344
|
-
),
|
|
345
|
-
},
|
|
346
|
-
document.body.appendChild(document.createElement('div'))
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
await nextTick();
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
createRangeInputTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
353
|
-
mountApp(
|
|
354
|
-
{
|
|
355
|
-
render: renderCompat((h) =>
|
|
356
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
357
|
-
h(AisRangeInput, { props: widgetParams }),
|
|
358
|
-
h(GlobalErrorSwallower),
|
|
359
|
-
])
|
|
360
|
-
),
|
|
361
|
-
},
|
|
362
|
-
document.body.appendChild(document.createElement('div'))
|
|
363
|
-
);
|
|
364
|
-
|
|
365
|
-
await nextTick();
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
createCurrentRefinementsTests(
|
|
369
|
-
async ({ instantSearchOptions, widgetParams }) => {
|
|
370
|
-
const CurrentRefinementsURL = createURLComponent({
|
|
371
|
-
connector: connectCurrentRefinements,
|
|
372
|
-
name: 'CurrentRefinements',
|
|
373
|
-
urlValue: {
|
|
374
|
-
attribute: 'brand',
|
|
375
|
-
type: 'disjunctive',
|
|
376
|
-
value: 'Apple',
|
|
377
|
-
label: 'Apple',
|
|
378
|
-
},
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
mountApp(
|
|
382
|
-
{
|
|
383
|
-
render: renderCompat((h) =>
|
|
384
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
385
|
-
h(CurrentRefinementsURL, { props: widgetParams }),
|
|
386
|
-
h(AisCurrentRefinements),
|
|
387
|
-
h(AisRefinementList, { props: { attribute: 'brand' } }),
|
|
388
|
-
h(GlobalErrorSwallower),
|
|
389
|
-
])
|
|
390
|
-
),
|
|
391
|
-
},
|
|
392
|
-
document.body.appendChild(document.createElement('div'))
|
|
393
|
-
);
|
|
394
|
-
|
|
395
|
-
await nextTick();
|
|
396
|
-
}
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
createHitsPerPageTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
400
|
-
const HitsPerPageURL = createURLComponent({
|
|
401
|
-
connector: connectHitsPerPage,
|
|
402
|
-
name: 'HitsPerPage',
|
|
403
|
-
requiredProps: ['items'],
|
|
404
|
-
urlValue: 12,
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
mountApp(
|
|
408
|
-
{
|
|
409
|
-
render: renderCompat((h) =>
|
|
410
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
411
|
-
h(HitsPerPageURL, { props: widgetParams }),
|
|
412
|
-
h(AisHitsPerPage, { props: widgetParams }),
|
|
413
|
-
h(GlobalErrorSwallower),
|
|
414
|
-
])
|
|
415
|
-
),
|
|
416
|
-
},
|
|
417
|
-
document.body.appendChild(document.createElement('div'))
|
|
418
|
-
);
|
|
419
|
-
|
|
420
|
-
await nextTick();
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
createNumericMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
424
|
-
const NumericMenuURL = createURLComponent({
|
|
425
|
-
connector: connectNumericMenu,
|
|
426
|
-
name: 'NumericMenu',
|
|
427
|
-
requiredProps: ['attribute', 'items'],
|
|
428
|
-
urlValue: encodeURI('{ "start": 500 }'),
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
mountApp(
|
|
432
|
-
{
|
|
433
|
-
render: renderCompat((h) =>
|
|
434
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
435
|
-
h(NumericMenuURL, { props: widgetParams }),
|
|
436
|
-
h(AisNumericMenu, { props: widgetParams }),
|
|
437
|
-
h(GlobalErrorSwallower),
|
|
438
|
-
])
|
|
439
|
-
),
|
|
440
|
-
},
|
|
441
|
-
document.body.appendChild(document.createElement('div'))
|
|
442
|
-
);
|
|
443
|
-
|
|
444
|
-
await nextTick();
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
createRatingMenuTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
448
|
-
const RatingMenuURL = createURLComponent({
|
|
449
|
-
connector: connectRatingMenu,
|
|
450
|
-
name: 'RatingMenu',
|
|
451
|
-
requiredProps: ['attribute'],
|
|
452
|
-
urlValue: encodeURI('5'),
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
mountApp(
|
|
456
|
-
{
|
|
457
|
-
render: renderCompat((h) =>
|
|
458
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
459
|
-
h(RatingMenuURL, { props: widgetParams }),
|
|
460
|
-
h(AisRatingMenu, { props: widgetParams }),
|
|
461
|
-
h(GlobalErrorSwallower),
|
|
462
|
-
])
|
|
463
|
-
),
|
|
464
|
-
},
|
|
465
|
-
document.body.appendChild(document.createElement('div'))
|
|
466
|
-
);
|
|
467
|
-
|
|
468
|
-
await nextTick();
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
createToggleRefinementTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
472
|
-
const ToggleRefinementURL = createURLComponent({
|
|
473
|
-
name: 'ToggleRefinement',
|
|
474
|
-
connector: connectToggleRefinement,
|
|
475
|
-
requiredProps: ['attribute', 'label'],
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
// Label is required in Vue
|
|
479
|
-
const props = {
|
|
480
|
-
...widgetParams,
|
|
481
|
-
label: 'Free Shipping',
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
mountApp(
|
|
485
|
-
{
|
|
486
|
-
render: renderCompat((h) =>
|
|
487
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
488
|
-
h(ToggleRefinementURL, { props }),
|
|
489
|
-
h(AisToggleRefinement, { props }),
|
|
490
|
-
h(GlobalErrorSwallower),
|
|
491
|
-
])
|
|
492
|
-
),
|
|
493
|
-
},
|
|
494
|
-
document.body.appendChild(document.createElement('div'))
|
|
495
|
-
);
|
|
496
|
-
|
|
497
|
-
await nextTick();
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
createInstantSearchTests(({ instantSearchOptions }) => {
|
|
501
|
-
mountApp(
|
|
502
|
-
{
|
|
503
|
-
render: renderCompat((h) =>
|
|
504
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
505
|
-
h(GlobalErrorSwallower),
|
|
506
|
-
])
|
|
507
|
-
),
|
|
508
|
-
},
|
|
509
|
-
document.body.appendChild(document.createElement('div'))
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
return {
|
|
513
|
-
algoliaAgents: [
|
|
514
|
-
`instantsearch.js (${
|
|
515
|
-
require('../../../instantsearch.js/package.json').version
|
|
516
|
-
})`,
|
|
517
|
-
`Vue InstantSearch (${
|
|
518
|
-
require('../../../vue-instantsearch/package.json').version
|
|
519
|
-
})`,
|
|
520
|
-
`Vue (${require('../util/vue-compat').version})`,
|
|
521
|
-
],
|
|
522
|
-
};
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
createSharedTests(async ({ instantSearchOptions, widgetParams }) => {
|
|
526
|
-
const MenuURL = createURLComponent({
|
|
527
|
-
connector: connectMenu,
|
|
528
|
-
name: 'Menu',
|
|
529
|
-
requiredProps: ['attribute'],
|
|
530
|
-
urlValue: 'value',
|
|
531
|
-
});
|
|
532
|
-
const PaginationURL = createURLComponent({
|
|
533
|
-
connector: connectPagination,
|
|
534
|
-
name: 'Pagination',
|
|
535
|
-
urlValue: 10,
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
mountApp(
|
|
539
|
-
{
|
|
540
|
-
render: renderCompat((h) =>
|
|
541
|
-
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
542
|
-
h(MenuURL, { props: widgetParams.menu }),
|
|
543
|
-
h(AisMenu, { props: widgetParams.menu }),
|
|
544
|
-
h(AisHits, { props: widgetParams.hits }),
|
|
545
|
-
h(PaginationURL, { props: widgetParams.pagination }),
|
|
546
|
-
h(AisPagination, { props: widgetParams.pagination }),
|
|
547
|
-
h(GlobalErrorSwallower),
|
|
548
|
-
])
|
|
549
|
-
),
|
|
550
|
-
},
|
|
551
|
-
document.body.appendChild(document.createElement('div'))
|
|
552
|
-
);
|
|
553
|
-
|
|
554
|
-
await nextTick();
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
function createURLComponent({ connector, name, urlValue, requiredProps = [] }) {
|
|
558
|
-
return {
|
|
559
|
-
name: `${name}URL`,
|
|
560
|
-
mixins: [createWidgetMixin({ connector })],
|
|
561
|
-
props: Object.fromEntries(
|
|
562
|
-
requiredProps.map((prop) => [prop, { required: true }])
|
|
563
|
-
),
|
|
564
|
-
computed: {
|
|
565
|
-
widgetParams() {
|
|
566
|
-
return Object.fromEntries(
|
|
567
|
-
requiredProps.map((prop) => [prop, this[prop]])
|
|
568
|
-
);
|
|
569
|
-
},
|
|
570
|
-
},
|
|
571
|
-
render: renderCompat(function (h) {
|
|
572
|
-
return this.state
|
|
573
|
-
? h(
|
|
574
|
-
'a',
|
|
575
|
-
{
|
|
576
|
-
attrs: {
|
|
577
|
-
'data-testid': `${name}-link`,
|
|
578
|
-
href: this.state.createURL(urlValue),
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
'LINK'
|
|
582
|
-
)
|
|
583
|
-
: null;
|
|
584
|
-
}),
|
|
585
|
-
};
|
|
586
|
-
}
|