Skip to content

Commit

Permalink
feat(connectPagination): add default value on getConfiguration (#3838)
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss authored and Haroenv committed Oct 23, 2019
1 parent 8c65249 commit aa4602c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/connectors/pagination/__tests__/connectPagination-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/pagination/
foo: 'bar',
});

expect(widget.getConfiguration).toBe(undefined);

const helper = algoliasearchHelper({});
helper.search = jest.fn();

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

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

const nextConfiguation = widget.getConfiguration();

expect(nextConfiguation.page).toBe(0);
});
});

describe('dispose', () => {
it('calls the unmount function', () => {
const helper = algoliasearchHelper({}, '');
Expand Down
6 changes: 6 additions & 0 deletions src/connectors/pagination/connectPagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export default function connectPagination(renderFn, unmountFn = noop) {
});

return {
getConfiguration() {
return {
page: 0,
};
},

init({ helper, createURL, instantSearchInstance }) {
this.refine = page => {
helper.setPage(page);
Expand Down
4 changes: 0 additions & 4 deletions src/widgets/pagination/__tests__/pagination-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ describe('pagination()', () => {
widget.init({ helper });
});

it('configures nothing', () => {
expect(widget.getConfiguration).toEqual(undefined);
});

it('sets the page', () => {
widget.refine(helper, 42);
expect(helper.setPage).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit aa4602c

Please sign in to comment.