Skip to content

Commit

Permalink
feat(connectVoiceSearch): add default value on getConfiguration (#3841)
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss authored and Haroenv committed Oct 23, 2019
1 parent aa4602c commit fb70363
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/connectors/voice-search/__tests__/connectVoiceSearch-test.js
Expand Up @@ -113,6 +113,18 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/voice-searc
expect(helper.search).toHaveBeenCalledTimes(1);
});

describe('getConfiguration', () => {
it('adds a `query` to the `SearchParameters`', () => {
const renderFn = () => {};
const makeWidget = connectVoiceSearch(renderFn);
const widget = makeWidget({});

const nextConfiguration = widget.getConfiguration();

expect(nextConfiguration.query).toBe('');
});
});

describe('dispose', () => {
it('calls the unmount function', () => {
const helper = algoliasearchHelper({}, '');
Expand Down
6 changes: 6 additions & 0 deletions src/connectors/voice-search/connectVoiceSearch.ts
Expand Up @@ -74,6 +74,12 @@ const connectVoiceSearch: VoiceSearchConnector = (
const { searchAsYouSpeak = false } = widgetParams;

return {
getConfiguration() {
return {
query: '',
};
},

init({ helper, instantSearchInstance }) {
(this as any)._refine = (query: string): void => {
if (query !== helper.state.query) {
Expand Down

0 comments on commit fb70363

Please sign in to comment.