Skip to content

Commit aa4602c

Browse files
samoussHaroenv
authored andcommitted
feat(connectPagination): add default value on getConfiguration (#3838)
1 parent 8c65249 commit aa4602c

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/connectors/pagination/__tests__/connectPagination-test.js

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

28-
expect(widget.getConfiguration).toBe(undefined);
29-
3028
const helper = algoliasearchHelper({});
3129
helper.search = jest.fn();
3230

@@ -254,6 +252,18 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/pagination/
254252
}
255253
});
256254

255+
describe('getConfiguration', () => {
256+
it('adds a `page` to the `SearchParameters`', () => {
257+
const renderFn = () => {};
258+
const makeWidget = connectPagination(renderFn);
259+
const widget = makeWidget();
260+
261+
const nextConfiguation = widget.getConfiguration();
262+
263+
expect(nextConfiguation.page).toBe(0);
264+
});
265+
});
266+
257267
describe('dispose', () => {
258268
it('calls the unmount function', () => {
259269
const helper = algoliasearchHelper({}, '');

src/connectors/pagination/connectPagination.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ export default function connectPagination(renderFn, unmountFn = noop) {
9898
});
9999

100100
return {
101+
getConfiguration() {
102+
return {
103+
page: 0,
104+
};
105+
},
106+
101107
init({ helper, createURL, instantSearchInstance }) {
102108
this.refine = page => {
103109
helper.setPage(page);

src/widgets/pagination/__tests__/pagination-test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ describe('pagination()', () => {
7272
widget.init({ helper });
7373
});
7474

75-
it('configures nothing', () => {
76-
expect(widget.getConfiguration).toEqual(undefined);
77-
});
78-
7975
it('sets the page', () => {
8076
widget.refine(helper, 42);
8177
expect(helper.setPage).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)