vue-instantsearch 4.8.2 → 4.8.4

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 CHANGED
@@ -16,7 +16,7 @@
16
16
  "autocomplete"
17
17
  ],
18
18
  "license": "MIT",
19
- "version": "4.8.2",
19
+ "version": "4.8.4",
20
20
  "files": [
21
21
  "vue2",
22
22
  "vue3",
@@ -35,7 +35,7 @@
35
35
  "test:exports:vue3": "node ./test/module/vue3/is-es-module.mjs && node ./test/module/vue3/is-cjs-module.cjs"
36
36
  },
37
37
  "dependencies": {
38
- "instantsearch.js": "4.50.2",
38
+ "instantsearch.js": "4.51.0",
39
39
  "mitt": "^2.1.0"
40
40
  },
41
41
  "peerDependencies": {
@@ -85,5 +85,5 @@
85
85
  "vuex": "3.5.1",
86
86
  "vuex4": "npm:vuex@4.0.0"
87
87
  },
88
- "gitHead": "929c1d782d17a0d743f8a16d8d7e2231534658e7"
88
+ "gitHead": "dbe09ac288e92ef1b277b5e6aea79fce1029d452"
89
89
  }
@@ -6,12 +6,16 @@
6
6
  :has-no-results="state.hasNoResults"
7
7
  :can-refine="state.canRefine"
8
8
  >
9
- <select :class="suit('select')" v-model="selected" @change="handleChange">
9
+ <select
10
+ :class="suit('select')"
11
+ @change="state.refine(Number($event.currentTarget.value))"
12
+ >
10
13
  <option
11
14
  v-for="item in state.items"
12
15
  :key="item.value"
13
16
  :class="suit('option')"
14
17
  :value="item.value"
18
+ :selected="item.isRefined"
15
19
  >
16
20
  {{ item.label }}
17
21
  </option>
@@ -50,11 +54,6 @@ export default {
50
54
  default: undefined,
51
55
  },
52
56
  },
53
- data() {
54
- return {
55
- selected: this.items.find((item) => item.default === true).value,
56
- };
57
- },
58
57
  computed: {
59
58
  widgetParams() {
60
59
  return {
@@ -63,10 +62,5 @@ export default {
63
62
  };
64
63
  },
65
64
  },
66
- methods: {
67
- handleChange() {
68
- this.state.refine(this.selected);
69
- },
70
- },
71
65
  };
72
66
  </script>
@@ -6,6 +6,8 @@ import { mount } from '../../../test/utils';
6
6
  import { __setState } from '../../mixins/widget';
7
7
  import HitsPerPage from '../HitsPerPage.vue';
8
8
  import '../../../test/utils/sortedHtmlSerializer';
9
+ import { getByRole } from '@testing-library/dom';
10
+ import userEvent from '@testing-library/user-event';
9
11
 
10
12
  jest.mock('../../mixins/widget');
11
13
  jest.mock('../../mixins/panel');
@@ -63,7 +65,7 @@ it('renders correctly', () => {
63
65
  expect(wrapper.html()).toMatchSnapshot();
64
66
  });
65
67
 
66
- it('calls `refine` with the `value` on `change`', async () => {
68
+ it('calls `refine` with the `value` on `change`', () => {
67
69
  __setState({
68
70
  ...defaultState,
69
71
  refine: jest.fn(),
@@ -73,11 +75,10 @@ it('calls `refine` with the `value` on `change`', async () => {
73
75
  propsData: defaultProps,
74
76
  });
75
77
 
76
- await wrapper.setData({
77
- selected: 20,
78
- });
79
-
80
- await wrapper.find('select').trigger('change');
78
+ userEvent.selectOptions(
79
+ getByRole(wrapper.element, 'combobox'),
80
+ getByRole(wrapper.element, 'option', { name: '20 results' })
81
+ );
81
82
 
82
83
  expect(wrapper.vm.state.refine).toHaveBeenLastCalledWith(20);
83
84
  });
@@ -6,6 +6,8 @@ import { mount } from '../../../test/utils';
6
6
  import { __setState } from '../../mixins/widget';
7
7
  import SortBy from '../SortBy.vue';
8
8
  import '../../../test/utils/sortedHtmlSerializer';
9
+ import userEvent from '@testing-library/user-event';
10
+ import { getByRole } from '@testing-library/dom';
9
11
 
10
12
  jest.mock('../../mixins/widget');
11
13
  jest.mock('../../mixins/panel');
@@ -90,7 +92,7 @@ it('renders with scoped slots', () => {
90
92
  expect(wrapper.html()).toMatchSnapshot();
91
93
  });
92
94
 
93
- it('calls `refine` when the selection changes with the `value`', async () => {
95
+ it('calls `refine` when the selection changes with the `value`', () => {
94
96
  const refine = jest.fn();
95
97
  __setState({
96
98
  ...defaultState,
@@ -101,14 +103,15 @@ it('calls `refine` when the selection changes with the `value`', async () => {
101
103
  ...defaultProps,
102
104
  },
103
105
  });
104
- // This is bad 👇🏽 but the only way for now to trigger changes
105
- // on a select: https://github.com/vuejs/vue-test-utils/issues/260
106
- const select = wrapper.find('select');
107
- select.element.value = 'some_index_quality';
108
- await select.trigger('change');
109
- const selectedOption = wrapper.find('option[value=some_index_quality]');
106
+
107
+ userEvent.selectOptions(
108
+ getByRole(wrapper.element, 'combobox'),
109
+ getByRole(wrapper.element, 'option', { name: 'Quality ascending' })
110
+ );
110
111
 
111
112
  expect(refine).toHaveBeenCalledTimes(1);
112
113
  expect(refine).toHaveBeenLastCalledWith('some_index_quality');
113
- expect(selectedOption.element.selected).toBe(true);
114
+ expect(
115
+ getByRole(wrapper.element, 'option', { name: 'Quality ascending' }).selected
116
+ ).toBe(true);
114
117
  });