vue-instantsearch 4.17.1 → 4.17.3
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-widgets.test.js +38 -0
- package/src/components/Hits.js +2 -5
- package/src/components/InfiniteHits.vue +2 -7
- package/src/components/PoweredBy.vue +2 -2
- package/src/components/RatingMenu.vue +36 -34
- package/src/components/__tests__/Hits.js +1 -1
- package/src/components/__tests__/InfiniteHits.js +1 -168
- package/src/components/__tests__/MenuSelect.js +0 -160
- package/src/components/__tests__/RatingMenu.js +0 -117
- package/src/components/__tests__/__snapshots__/InfiniteHits.js.snap +0 -110
- package/src/components/__tests__/__snapshots__/MenuSelect.js.snap +0 -39
- package/vue2/cjs/index.js +1 -1
- package/vue2/cjs/index.js.map +1 -1
- package/vue2/es/package.json.js +1 -1
- package/vue2/es/src/components/Hits.js +1 -1
- package/vue2/es/src/components/Hits.js.map +1 -1
- package/vue2/es/src/components/InfiniteHits.vue.js +1 -1
- package/vue2/es/src/components/InfiniteHits.vue_rollup-plugin-vue=script.js +1 -1
- package/vue2/es/src/components/PoweredBy.vue.js +1 -1
- package/vue2/es/src/components/RatingMenu.vue.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/cjs/index.js.map +1 -1
- package/vue3/es/package.json.js +1 -1
- package/vue3/es/src/components/Hits.js +1 -1
- package/vue3/es/src/components/Hits.js.map +1 -1
- package/vue3/es/src/components/InfiniteHits.vue.js +1 -1
- package/vue3/es/src/components/InfiniteHits.vue_vue&type=script&lang.js +1 -1
- package/vue3/es/src/components/InfiniteHits.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/InfiniteHits.vue_vue&type=template&id=1b2a109e&lang.js +2 -0
- package/vue3/es/src/components/InfiniteHits.vue_vue&type=template&id=1b2a109e&lang.js.map +1 -0
- package/vue3/es/src/components/PoweredBy.vue.js +1 -1
- package/vue3/es/src/components/PoweredBy.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/PoweredBy.vue_vue&type=template&id=1cd6879e&lang.js +2 -0
- package/vue3/es/src/components/PoweredBy.vue_vue&type=template&id=1cd6879e&lang.js.map +1 -0
- package/vue3/es/src/components/RatingMenu.vue.js +1 -1
- package/vue3/es/src/components/RatingMenu.vue_vue&type=script&lang.js.map +1 -1
- package/vue3/es/src/components/RatingMenu.vue_vue&type=template&id=c025dd38&lang.js +2 -0
- package/vue3/es/src/components/RatingMenu.vue_vue&type=template&id=c025dd38&lang.js.map +1 -0
- package/vue3/umd/index.js +1 -1
- package/vue3/umd/index.js.map +1 -1
- package/src/components/__tests__/PoweredBy.js +0 -37
- package/src/components/__tests__/__snapshots__/PoweredBy.js.snap +0 -51
- package/src/components/__tests__/__snapshots__/RatingMenu.js.snap +0 -487
- package/vue3/es/src/components/InfiniteHits.vue_vue&type=template&id=39939af3&lang.js +0 -2
- package/vue3/es/src/components/InfiniteHits.vue_vue&type=template&id=39939af3&lang.js.map +0 -1
- package/vue3/es/src/components/PoweredBy.vue_vue&type=template&id=85db7eac&lang.js +0 -2
- package/vue3/es/src/components/PoweredBy.vue_vue&type=template&id=85db7eac&lang.js.map +0 -1
- package/vue3/es/src/components/RatingMenu.vue_vue&type=template&id=6effe1ff&lang.js +0 -2
- package/vue3/es/src/components/RatingMenu.vue_vue&type=template&id=6effe1ff&lang.js.map +0 -1
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"autocomplete"
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"version": "4.17.
|
|
19
|
+
"version": "4.17.3",
|
|
20
20
|
"files": [
|
|
21
21
|
"vue2",
|
|
22
22
|
"vue3",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"instantsearch-ui-components": "0.6.0",
|
|
40
|
-
"instantsearch.js": "4.
|
|
40
|
+
"instantsearch.js": "4.71.1",
|
|
41
41
|
"mitt": "^2.1.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@vue/test-utils2": "npm:@vue/test-utils@2.0.0-rc.11",
|
|
64
64
|
"algoliasearch": "4.23.2",
|
|
65
65
|
"algoliasearch-helper": "3.21.0",
|
|
66
|
-
"instantsearch.css": "8.2.
|
|
66
|
+
"instantsearch.css": "8.2.1",
|
|
67
67
|
"rollup": "1.32.1",
|
|
68
68
|
"rollup-plugin-babel": "4.4.0",
|
|
69
69
|
"rollup-plugin-buble": "0.19.6",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"vuex": "3.5.1",
|
|
90
90
|
"vuex4": "npm:vuex@4.0.0"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "443c2f875bd5ddd5cc94285b49c1e8c05df5e0f6"
|
|
93
93
|
}
|
|
@@ -26,6 +26,8 @@ import {
|
|
|
26
26
|
AisStats,
|
|
27
27
|
AisRatingMenu,
|
|
28
28
|
AisNumericMenu,
|
|
29
|
+
AisPoweredBy,
|
|
30
|
+
AisMenuSelect,
|
|
29
31
|
} from '../instantsearch';
|
|
30
32
|
import { renderCompat } from '../util/vue-compat';
|
|
31
33
|
|
|
@@ -174,6 +176,9 @@ const testSetups = {
|
|
|
174
176
|
),
|
|
175
177
|
},
|
|
176
178
|
}),
|
|
179
|
+
h('div', { attrs: { id: 'hits-with-defaults' } }, [
|
|
180
|
+
h(AisInfiniteHits, { props: widgetParams }),
|
|
181
|
+
]),
|
|
177
182
|
h(AisIndex, { props: { indexName: 'nested' } }, [
|
|
178
183
|
h(AisInfiniteHits, {
|
|
179
184
|
attrs: { id: 'nested-hits' },
|
|
@@ -517,6 +522,38 @@ const testSetups = {
|
|
|
517
522
|
createLookingSimilarWidgetTests() {
|
|
518
523
|
throw new Error('LookingSimilar is not supported in Vue InstantSearch');
|
|
519
524
|
},
|
|
525
|
+
createPoweredByWidgetTests({ instantSearchOptions, widgetParams }) {
|
|
526
|
+
mountApp(
|
|
527
|
+
{
|
|
528
|
+
render: renderCompat((h) =>
|
|
529
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
530
|
+
h(AisPoweredBy, { props: widgetParams }),
|
|
531
|
+
h(GlobalErrorSwallower),
|
|
532
|
+
])
|
|
533
|
+
),
|
|
534
|
+
},
|
|
535
|
+
document.body.appendChild(document.createElement('div'))
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
return {
|
|
539
|
+
flavor: 'vue-instantsearch',
|
|
540
|
+
};
|
|
541
|
+
},
|
|
542
|
+
async createMenuSelectWidgetTests({ instantSearchOptions, widgetParams }) {
|
|
543
|
+
mountApp(
|
|
544
|
+
{
|
|
545
|
+
render: renderCompat((h) =>
|
|
546
|
+
h(AisInstantSearch, { props: instantSearchOptions }, [
|
|
547
|
+
h(AisMenuSelect, { props: widgetParams }),
|
|
548
|
+
h(GlobalErrorSwallower),
|
|
549
|
+
])
|
|
550
|
+
),
|
|
551
|
+
},
|
|
552
|
+
document.body.appendChild(document.createElement('div'))
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
await nextTick();
|
|
556
|
+
},
|
|
520
557
|
};
|
|
521
558
|
|
|
522
559
|
const testOptions = {
|
|
@@ -553,6 +590,7 @@ const testOptions = {
|
|
|
553
590
|
createLookingSimilarWidgetTests: {
|
|
554
591
|
skippedTests: { 'LookingSimilar widget common tests': true },
|
|
555
592
|
},
|
|
593
|
+
createPoweredByWidgetTests: undefined,
|
|
556
594
|
};
|
|
557
595
|
|
|
558
596
|
describe('Common widget tests (Vue InstantSearch)', () => {
|
package/src/components/Hits.js
CHANGED
|
@@ -29,9 +29,6 @@ export default {
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
computed: {
|
|
32
|
-
items() {
|
|
33
|
-
return this.state.hits;
|
|
34
|
-
},
|
|
35
32
|
widgetParams() {
|
|
36
33
|
return {
|
|
37
34
|
escapeHTML: this.escapeHTML,
|
|
@@ -91,7 +88,7 @@ export default {
|
|
|
91
88
|
},
|
|
92
89
|
[
|
|
93
90
|
defaultSlot({
|
|
94
|
-
items: this.state.
|
|
91
|
+
items: this.state.items,
|
|
95
92
|
insights: this.state.insights,
|
|
96
93
|
sendEvent: this.state.sendEvent,
|
|
97
94
|
}),
|
|
@@ -100,7 +97,7 @@ export default {
|
|
|
100
97
|
}
|
|
101
98
|
|
|
102
99
|
return h(createHitsComponent({ createElement: h }), {
|
|
103
|
-
hits: this.state.
|
|
100
|
+
hits: this.state.items,
|
|
104
101
|
itemComponent,
|
|
105
102
|
sendEvent: this.state.sendEvent,
|
|
106
103
|
classNames: this.classNames && {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
</slot>
|
|
21
21
|
|
|
22
22
|
<slot
|
|
23
|
-
:items="items"
|
|
23
|
+
:items="state.items"
|
|
24
24
|
:results="state.results"
|
|
25
25
|
:is-last-page="state.isLastPage"
|
|
26
26
|
:refine-previous="refinePrevious"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
>
|
|
32
32
|
<ol :class="suit('list')">
|
|
33
33
|
<li
|
|
34
|
-
v-for="(item, index) in items"
|
|
34
|
+
v-for="(item, index) in state.items"
|
|
35
35
|
:class="suit('item')"
|
|
36
36
|
:key="item.objectID"
|
|
37
37
|
@click="state.sendEvent('click:internal', item, 'Hit Clicked')"
|
|
@@ -117,11 +117,6 @@ export default {
|
|
|
117
117
|
cache: this.cache,
|
|
118
118
|
};
|
|
119
119
|
},
|
|
120
|
-
items() {
|
|
121
|
-
// Fixes InstantSearch.js connectors API: every list
|
|
122
|
-
// of things must be called `items`
|
|
123
|
-
return this.state.hits;
|
|
124
|
-
},
|
|
125
120
|
},
|
|
126
121
|
methods: {
|
|
127
122
|
refinePrevious() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="suit()">
|
|
2
|
+
<div :class="[suit(), suit('', theme)]">
|
|
3
3
|
<a
|
|
4
4
|
:class="suit('link')"
|
|
5
5
|
:href="algoliaUrl"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
viewBox="0 0 572 64"
|
|
14
14
|
>
|
|
15
15
|
<path
|
|
16
|
-
:fill="theme === 'dark' ? '#FFF' : '#
|
|
16
|
+
:fill="theme === 'dark' ? '#FFF' : '#36395A'"
|
|
17
17
|
d="M16 48.3c-3.4 0-6.3-.6-8.7-1.7A12.4 12.4 0 0 1 1.9 42C.6 40 0 38 0 35.4h6.5a6.7 6.7 0 0 0 3.9 6c1.4.7 3.3 1.1 5.6 1.1 2.2 0 4-.3 5.4-1a7 7 0 0 0 3-2.4 6 6 0 0 0 1-3.4c0-1.5-.6-2.8-1.9-3.7-1.3-1-3.3-1.6-5.9-1.8l-4-.4c-3.7-.3-6.6-1.4-8.8-3.4a10 10 0 0 1-3.3-7.9c0-2.4.6-4.6 1.8-6.4a12 12 0 0 1 5-4.3c2.2-1 4.7-1.6 7.5-1.6s5.5.5 7.6 1.6a12 12 0 0 1 5 4.4c1.2 1.8 1.8 4 1.8 6.7h-6.5a6.4 6.4 0 0 0-3.5-5.9c-1-.6-2.6-1-4.4-1s-3.2.3-4.4 1c-1.1.6-2 1.4-2.6 2.4-.5 1-.8 2-.8 3.1a5 5 0 0 0 1.5 3.6c1 1 2.6 1.7 4.7 1.9l4 .3c2.8.2 5.2.8 7.2 1.8 2.1 1 3.7 2.2 4.9 3.8a9.7 9.7 0 0 1 1.7 5.8c0 2.5-.7 4.7-2 6.6a13 13 0 0 1-5.6 4.4c-2.4 1-5.2 1.6-8.4 1.6Zm35.6 0c-2.6 0-4.8-.4-6.7-1.3a13 13 0 0 1-4.7-3.5 17.1 17.1 0 0 1-3.6-10.4v-1c0-2 .3-3.8 1-5.6a13 13 0 0 1 7.3-8.3 15 15 0 0 1 6.3-1.4A13.2 13.2 0 0 1 64 24.3c1 2.2 1.6 4.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.9-.4a4 4 0 0 0 2-1.4c.4-.7.9-1.6 1.2-2.7l8.6-30.9h6.2l-9.3 32.4a14 14 0 0 1-2.5 5 8.9 8.9 0 0 1-4 2.8c-1.5.6-3.4.9-5.6.9h-4.4Zm9-12.2v-5.2h6.4v5.2H248Z"
|
|
18
18
|
/>
|
|
19
19
|
<path
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
:send-event="state.sendEvent"
|
|
8
8
|
:can-refine="state.canRefine"
|
|
9
9
|
>
|
|
10
|
-
<svg
|
|
10
|
+
<svg style="display: none">
|
|
11
11
|
<symbol id="ais-RatingMenu-starSymbol" viewBox="0 0 24 24">
|
|
12
12
|
<path
|
|
13
13
|
d="M12 .288l2.833 8.718h9.167l-7.417 5.389 2.833 8.718-7.416-5.388-7.417 5.388 2.833-8.718-7.416-5.389h9.167z"
|
|
@@ -26,41 +26,43 @@
|
|
|
26
26
|
:key="key"
|
|
27
27
|
:class="[suit('item'), item.isRefined && suit('item', 'selected')]"
|
|
28
28
|
>
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
<div>
|
|
30
|
+
<a
|
|
31
|
+
:href="state.createURL(item.value)"
|
|
32
|
+
:aria-label="`${item.value} & up`"
|
|
33
|
+
:class="suit('link')"
|
|
34
|
+
@click.prevent="state.refine(item.value)"
|
|
35
|
+
>
|
|
36
|
+
<template v-for="(full, n) in item.stars">
|
|
37
|
+
<svg
|
|
38
|
+
v-if="full"
|
|
39
|
+
aria-hidden="true"
|
|
40
|
+
width="24"
|
|
41
|
+
height="24"
|
|
42
|
+
:class="[suit('starIcon'), suit('starIcon--full')]"
|
|
43
|
+
:key="n + '-full'"
|
|
44
|
+
>
|
|
45
|
+
<use xlink:href="#ais-RatingMenu-starSymbol" />
|
|
46
|
+
</svg>
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
<svg
|
|
49
|
+
v-else
|
|
50
|
+
:class="[suit('starIcon'), suit('starIcon--empty')]"
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
width="24"
|
|
53
|
+
height="24"
|
|
54
|
+
:key="n + '-empty'"
|
|
55
|
+
>
|
|
56
|
+
<use xlink:href="#ais-RatingMenu-starEmptySymbol" />
|
|
57
|
+
</svg>
|
|
58
|
+
</template>
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
<span :class="suit('label')" aria-hidden="true">
|
|
61
|
+
<slot name="andUp">& Up</slot>
|
|
62
|
+
</span>
|
|
63
|
+
<span :class="suit('count')">{{ item.count }}</span>
|
|
64
|
+
</a>
|
|
65
|
+
</div>
|
|
64
66
|
</li>
|
|
65
67
|
</ul>
|
|
66
68
|
</slot>
|
|
@@ -16,7 +16,7 @@ const defaultState = {
|
|
|
16
16
|
transformItems: (items) => items,
|
|
17
17
|
},
|
|
18
18
|
sendEvent: jest.fn(),
|
|
19
|
-
|
|
19
|
+
items: [
|
|
20
20
|
{
|
|
21
21
|
objectID: '00001',
|
|
22
22
|
},
|
|
@@ -42,79 +42,6 @@ const defaultState = {
|
|
|
42
42
|
showPrevious: () => {},
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
it('accepts a escapeHTML prop', () => {
|
|
46
|
-
__setState({
|
|
47
|
-
...defaultState,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const wrapper = mount(InfiniteHits, {
|
|
51
|
-
propsData: {
|
|
52
|
-
escapeHTML: true,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
expect(wrapper.vm.widgetParams.escapeHTML).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('accepts a transformItems prop', () => {
|
|
60
|
-
__setState({
|
|
61
|
-
...defaultState,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const transformItems = () => {};
|
|
65
|
-
|
|
66
|
-
const wrapper = mount(InfiniteHits, {
|
|
67
|
-
propsData: {
|
|
68
|
-
transformItems,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
expect(wrapper.vm.widgetParams.transformItems).toBe(transformItems);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('accepts a showPrevious prop', () => {
|
|
76
|
-
__setState({
|
|
77
|
-
...defaultState,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const wrapper = mount(InfiniteHits, {
|
|
81
|
-
propsData: {
|
|
82
|
-
showPrevious: true,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
expect(wrapper.vm.widgetParams.showPrevious).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('accepts a cache prop', () => {
|
|
90
|
-
__setState({
|
|
91
|
-
...defaultState,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const cache = {
|
|
95
|
-
read: () => {},
|
|
96
|
-
write: () => {},
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const wrapper = mount(InfiniteHits, {
|
|
100
|
-
propsData: {
|
|
101
|
-
cache,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
expect(wrapper.vm.widgetParams.cache).toEqual(cache);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('renders correctly', () => {
|
|
109
|
-
__setState({
|
|
110
|
-
...defaultState,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const wrapper = mount(InfiniteHits);
|
|
114
|
-
|
|
115
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
45
|
it('renders correctly with a custom rendering', () => {
|
|
119
46
|
__setState({
|
|
120
47
|
...defaultState,
|
|
@@ -159,100 +86,6 @@ it('renders correctly with a custom item rendering', () => {
|
|
|
159
86
|
expect(wrapper.html()).toMatchSnapshot();
|
|
160
87
|
});
|
|
161
88
|
|
|
162
|
-
it('renders correctly on the first page', () => {
|
|
163
|
-
__setState({
|
|
164
|
-
...defaultState,
|
|
165
|
-
isFirstPage: true,
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
const wrapper = mount(InfiniteHits, {
|
|
169
|
-
propsData: {
|
|
170
|
-
showPrevious: true,
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
const previousButton = wrapper.find('.ais-InfiniteHits-loadPrevious');
|
|
175
|
-
|
|
176
|
-
expect(previousButton.exists()).toEqual(true);
|
|
177
|
-
expect(
|
|
178
|
-
previousButton.classes('ais-InfiniteHits-loadPrevious--disabled')
|
|
179
|
-
).toEqual(true);
|
|
180
|
-
expect(previousButton).vueToBeDisabled();
|
|
181
|
-
expect(wrapper.htmlCompat()).toMatchSnapshot();
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('renders correctly on the last page', () => {
|
|
185
|
-
__setState({
|
|
186
|
-
...defaultState,
|
|
187
|
-
isLastPage: true,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const wrapper = mount(InfiniteHits);
|
|
191
|
-
|
|
192
|
-
expect(wrapper.htmlCompat()).toMatchSnapshot();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('renders correctly when not on the first page', () => {
|
|
196
|
-
__setState({
|
|
197
|
-
...defaultState,
|
|
198
|
-
isFirstPage: false,
|
|
199
|
-
isLastPage: false,
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
const wrapper = mount(InfiniteHits, {
|
|
203
|
-
propsData: {
|
|
204
|
-
showPrevious: true,
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
const previousButton = wrapper.find('.ais-InfiniteHits-loadPrevious');
|
|
209
|
-
|
|
210
|
-
expect(previousButton.exists()).toEqual(true);
|
|
211
|
-
expect(
|
|
212
|
-
previousButton.classes('ais-InfiniteHits-loadPrevious--disabled')
|
|
213
|
-
).toEqual(false);
|
|
214
|
-
expect(previousButton.attributes('disabled')).toEqual(undefined);
|
|
215
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('expect to call showPrevious on click', async () => {
|
|
219
|
-
const showPrevious = jest.fn();
|
|
220
|
-
|
|
221
|
-
__setState({
|
|
222
|
-
...defaultState,
|
|
223
|
-
showPrevious,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
const wrapper = mount(InfiniteHits, {
|
|
227
|
-
propsData: {
|
|
228
|
-
showPrevious: true,
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
expect(showPrevious).toHaveBeenCalledTimes(0);
|
|
233
|
-
|
|
234
|
-
await wrapper.find('.ais-InfiniteHits-loadPrevious').trigger('click');
|
|
235
|
-
|
|
236
|
-
expect(showPrevious).toHaveBeenCalledTimes(1);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('expect to call showMore on click', async () => {
|
|
240
|
-
const showMore = jest.fn();
|
|
241
|
-
|
|
242
|
-
__setState({
|
|
243
|
-
...defaultState,
|
|
244
|
-
showMore,
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
const wrapper = mount(InfiniteHits);
|
|
248
|
-
|
|
249
|
-
expect(showMore).not.toHaveBeenCalled();
|
|
250
|
-
|
|
251
|
-
await wrapper.find('.ais-InfiniteHits-loadMore').trigger('click');
|
|
252
|
-
|
|
253
|
-
expect(showMore).toHaveBeenCalled();
|
|
254
|
-
});
|
|
255
|
-
|
|
256
89
|
it('exposes insights prop to the default slot', async () => {
|
|
257
90
|
const insights = jest.fn();
|
|
258
91
|
|
|
@@ -23,92 +23,7 @@ const defaultProps = {
|
|
|
23
23
|
attribute: 'brand',
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
it('accepts an attribute prop', () => {
|
|
27
|
-
__setState({
|
|
28
|
-
...defaultState,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const props = {
|
|
32
|
-
...defaultProps,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const wrapper = mount(MenuSelect, {
|
|
36
|
-
propsData: props,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
expect(wrapper.vm.widgetParams.attribute).toBe('brand');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('accepts a limit prop', () => {
|
|
43
|
-
__setState({
|
|
44
|
-
...defaultState,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const props = {
|
|
48
|
-
...defaultProps,
|
|
49
|
-
limit: 5,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const wrapper = mount(MenuSelect, {
|
|
53
|
-
propsData: props,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
expect(wrapper.vm.widgetParams.limit).toBe(5);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('accepts a sortBy prop', () => {
|
|
60
|
-
__setState({
|
|
61
|
-
...defaultState,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const props = {
|
|
65
|
-
...defaultProps,
|
|
66
|
-
sortBy: ['name:desc'],
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const wrapper = mount(MenuSelect, {
|
|
70
|
-
propsData: props,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
expect(wrapper.vm.widgetParams.sortBy).toEqual(['name:desc']);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('accepts a transformItems prop', () => {
|
|
77
|
-
__setState({
|
|
78
|
-
...defaultState,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const transformItems = () => {};
|
|
82
|
-
|
|
83
|
-
const props = {
|
|
84
|
-
...defaultProps,
|
|
85
|
-
transformItems,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const wrapper = mount(MenuSelect, {
|
|
89
|
-
propsData: props,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
expect(wrapper.vm.widgetParams.transformItems).toBe(transformItems);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
26
|
describe('default render', () => {
|
|
96
|
-
it('renders correctly', () => {
|
|
97
|
-
__setState({
|
|
98
|
-
...defaultState,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const props = {
|
|
102
|
-
...defaultProps,
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const wrapper = mount(MenuSelect, {
|
|
106
|
-
propsData: props,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
27
|
it('renders correctly with custom label', () => {
|
|
113
28
|
__setState({
|
|
114
29
|
...defaultState,
|
|
@@ -129,81 +44,6 @@ describe('default render', () => {
|
|
|
129
44
|
expect(wrapper.find('option').html()).toContain('None');
|
|
130
45
|
expect(wrapper.html()).toMatchSnapshot();
|
|
131
46
|
});
|
|
132
|
-
|
|
133
|
-
it('renders correctly with a selected value', () => {
|
|
134
|
-
__setState({
|
|
135
|
-
...defaultState,
|
|
136
|
-
items: [
|
|
137
|
-
{ label: 'Apple', value: 'Apple', isRefined: false, count: 50 },
|
|
138
|
-
{ label: 'Samsung', value: 'Samsung', isRefined: true, count: 20 },
|
|
139
|
-
{ label: 'Sony', value: 'Sony', isRefined: false, count: 15 },
|
|
140
|
-
],
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const props = {
|
|
144
|
-
...defaultProps,
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const wrapper = mount(MenuSelect, {
|
|
148
|
-
propsData: props,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const selected = wrapper.find('[value="Samsung"]');
|
|
152
|
-
const options = wrapper.findAll('option:not([value="Samsung"])');
|
|
153
|
-
|
|
154
|
-
expect(selected.element.selected).toBe(true);
|
|
155
|
-
|
|
156
|
-
for (let i = 0; i < options.length; i++) {
|
|
157
|
-
expect((options[i] || options.at(i)).element.selected).toBe(false);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('renders correctly without refinements', () => {
|
|
162
|
-
__setState({
|
|
163
|
-
...defaultState,
|
|
164
|
-
canRefine: false,
|
|
165
|
-
items: [],
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
const props = {
|
|
169
|
-
...defaultProps,
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const wrapper = mount(MenuSelect, {
|
|
173
|
-
propsData: props,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('calls refine on select change', async () => {
|
|
180
|
-
const refine = jest.fn();
|
|
181
|
-
|
|
182
|
-
__setState({
|
|
183
|
-
...defaultState,
|
|
184
|
-
refine,
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
const props = {
|
|
188
|
-
...defaultProps,
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const wrapper = mount(MenuSelect, {
|
|
192
|
-
propsData: props,
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
expect(refine).not.toHaveBeenCalled();
|
|
196
|
-
|
|
197
|
-
const select = wrapper.find('select');
|
|
198
|
-
|
|
199
|
-
// Simulate the change
|
|
200
|
-
select.element.value = 'Apple';
|
|
201
|
-
|
|
202
|
-
await select.trigger('change');
|
|
203
|
-
|
|
204
|
-
expect(refine).toHaveBeenCalledTimes(1);
|
|
205
|
-
expect(refine).toHaveBeenCalledWith('Apple');
|
|
206
|
-
});
|
|
207
47
|
});
|
|
208
48
|
|
|
209
49
|
it('exposes send-event method for insights middleware', async () => {
|