Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/vue-instantsearch/src/components/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,23 @@ export default {
};
},
props: {
// Not `required` because it's optional when `isolated` is `true`. The
// underlying index widget throws when neither `indexName` nor `isolated`
// is provided.
indexName: {
type: String,
required: true,
required: false,
default: undefined,
},
indexId: {
type: String,
required: false,
},
isolated: {
type: Boolean,
required: false,
default: false,
},
},
render: renderCompat(function (h) {
return h('div', {}, getDefaultSlot(this));
Expand All @@ -43,6 +52,7 @@ export default {
return {
indexName: this.indexName,
indexId: this.indexId,
isolated: this.isolated,
};
},
},
Expand Down
15 changes: 15 additions & 0 deletions packages/vue-instantsearch/src/components/__tests__/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ it('passes props to widgetParams', () => {
expect(wrapper.vm.widgetParams).toEqual({
indexName: 'the name',
indexId: 'the id',
isolated: false,
});
});

it('passes the `isolated` prop to widgetParams without an `indexName`', () => {
const wrapper = mount(Index, {
propsData: {
isolated: true,
},
});

expect(wrapper.vm.widgetParams).toEqual({
indexName: undefined,
indexId: undefined,
isolated: true,
});
});

Expand Down
Loading