Skip to content

Commit

Permalink
test(js): add test for getAlgoliaFacetHits
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Feb 18, 2021
1 parent 3ec4b0e commit 8c135a4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/autocomplete-js/src/__tests__/getAlgoliaFacetHits.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import algoliaPreset from '@algolia/autocomplete-preset-algolia';

import { createSearchClient } from '../../../../test/utils';
import { getAlgoliaFacetHits } from '../getAlgoliaFacetHits';
import { version } from '../version';

jest.mock('@algolia/autocomplete-preset-algolia', () => {
const module = jest.requireActual('@algolia/autocomplete-preset-algolia');

return {
...module,
getAlgoliaFacetHits: jest.fn(),
};
});

describe('getAlgoliaFacetHits', () => {
test('forwards params to the preset function', () => {
const searchClient = createSearchClient();

getAlgoliaFacetHits({ searchClient, queries: [] });

expect(algoliaPreset.getAlgoliaFacetHits).toHaveBeenCalledTimes(1);
expect(algoliaPreset.getAlgoliaFacetHits).toHaveBeenCalledWith({
searchClient,
queries: [],
userAgents: [{ segment: 'autocomplete-js', version }],
});
});
});

0 comments on commit 8c135a4

Please sign in to comment.