Skip to content

Commit

Permalink
fix(infiniteHits): update lifecycle state (#3983)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored and Haroenv committed Oct 23, 2019
1 parent 798e3c1 commit 4b8bee5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
28 changes: 24 additions & 4 deletions src/connectors/infinite-hits/__tests__/connectInfiniteHits-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,16 +655,36 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/infinite-hi
});

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

const nextConfiguration = widget.getConfiguration!(
new SearchParameters()
expect(widget.getConfiguration!(new SearchParameters())).toBeInstanceOf(
SearchParameters
);
});

it('adds a `page` to the `SearchParameters`', () => {
const renderFn = (): void => {};
const makeWidget = connectInfiniteHits(renderFn);
const widget = makeWidget({});

expect(widget.getConfiguration!(new SearchParameters()).page).toEqual(0);
});

it('supports previous `page` from the `SearchParameters`', () => {
const renderFn = (): void => {};
const makeWidget = connectInfiniteHits(renderFn);
const widget = makeWidget({});

expect(
widget.getConfiguration!(new SearchParameters({ page: 0 })).page
).toEqual(0);

expect(nextConfiguration.page).toBe(0);
expect(
widget.getConfiguration!(new SearchParameters({ page: 6 })).page
).toEqual(6);
});

it('adds the TAG_PLACEHOLDER to the `SearchParameters`', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/connectors/infinite-hits/connectInfiniteHits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const connectInfiniteHits: InfiniteHitsConnector = (

getConfiguration(config) {
const parameters = {
page: 0,
page: config.page || 0,
};

if (!escapeHTML) {
Expand Down

0 comments on commit 4b8bee5

Please sign in to comment.