Skip to content

Commit c3a7d69

Browse files
samoussHaroenv
authored andcommitted
feat(connectSearchBox): mount with a default query (#3840)
1 parent fb70363 commit c3a7d69

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/connectors/search-box/__tests__/connectSearchBox-test.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/search-box/
2424
foo: 'bar',
2525
});
2626

27-
expect(widget.getConfiguration).toBe(undefined);
28-
2927
const helper = algoliasearchHelper({});
3028
helper.search = () => {};
3129

@@ -276,6 +274,18 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/search-box/
276274
expect(helper.search).toHaveBeenCalledTimes(1);
277275
});
278276

277+
describe('getConfiguration', () => {
278+
it('adds a `query` to the `SearchParameters`', () => {
279+
const renderFn = () => {};
280+
const makeWidget = connectSearchBox(renderFn);
281+
const widget = makeWidget();
282+
283+
const nextConfiguration = widget.getConfiguration();
284+
285+
expect(nextConfiguration.query).toBe('');
286+
});
287+
});
288+
279289
describe('dispose', () => {
280290
it('calls the unmount function', () => {
281291
const helper = algoliasearchHelper({}, '');

src/connectors/search-box/connectSearchBox.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ export default function connectSearchBox(renderFn, unmountFn = noop) {
8383
this._clear();
8484
},
8585

86+
getConfiguration() {
87+
return {
88+
query: '',
89+
};
90+
},
91+
8692
init({ helper, instantSearchInstance }) {
8793
this._cachedClear = this._cachedClear.bind(this);
8894
this._clear = clear(helper);

0 commit comments

Comments
 (0)