Skip to content

Commit

Permalink
fix(voiceSearch): update lifecycle state (#3982)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored and Haroenv committed Oct 23, 2019
1 parent 6e55ba6 commit 798e3c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/connectors/voice-search/__tests__/connectVoiceSearch-test.js
Expand Up @@ -141,7 +141,29 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/voice-searc

const nextConfiguration = widget.getConfiguration(new SearchParameters());

expect(nextConfiguration.query).toBe('');
expect(nextConfiguration).toEqual(
new SearchParameters({
query: '',
})
);
});

it('support previous `query` from the `SearchParameters`', () => {
const renderFn = () => {};
const makeWidget = connectVoiceSearch(renderFn);
const widget = makeWidget({});

const nextConfiguration = widget.getConfiguration(
new SearchParameters({
query: 'Previous query',
})
);

expect(nextConfiguration).toEqual(
new SearchParameters({
query: 'Previous query',
})
);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/connectors/voice-search/connectVoiceSearch.ts
Expand Up @@ -77,7 +77,7 @@ const connectVoiceSearch: VoiceSearchConnector = (
$$type: 'ais.voiceSearch',

getConfiguration(config) {
return config.setQuery('');
return config.setQuery(config.query || '');
},

init({ helper, instantSearchInstance }) {
Expand Down

0 comments on commit 798e3c1

Please sign in to comment.