Skip to content

Commit

Permalink
Merge branch 'develop' into feat/2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
bobylito authored May 29, 2018
2 parents 3de8c2b + bbf9f8f commit d1f99fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/widgets/infinite-hits/__tests__/infinite-hits-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ describe('infiniteHits()', () => {
expect(ReactDOM.render.secondCall.args[1]).toEqual(container);
});

it('does not accept both item and allItems templates', () => {
expect(
infiniteHits.bind({ container, templates: { item: '', allItems: '' } })
it('does not accept allItems templates', () => {
expect(() =>
infiniteHits({ container, templates: { allItems: '' } })
).toThrow();

expect(() =>
infiniteHits({ container, templates: { allItems: 'not empty' } })
).toThrow();

expect(() =>
infiniteHits({ container, templates: { allItems: () => 'template' } })
).toThrow();
});

Expand Down
8 changes: 8 additions & 0 deletions src/widgets/infinite-hits/infinite-hits.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ export default function infiniteHits({
throw new Error(`Must provide a container.${usage}`);
}

// We have this specific check because unlike the hits, infiniteHits does not support this template.
// This can be misleading as they are very similar.
if (templates.allItems !== undefined) {
throw new Error(
'allItems is not a valid template for the infiniteHits widget'
);
}

const containerNode = getContainerNode(container);
const cssClasses = {
root: cx(bem(null), userCssClasses.root),
Expand Down

0 comments on commit d1f99fb

Please sign in to comment.