diff --git a/packages/autocomplete-preset-algolia/src/__tests__/results.test.ts b/packages/autocomplete-preset-algolia/src/__tests__/results.test.ts index 38c70c3a6..199680a8e 100644 --- a/packages/autocomplete-preset-algolia/src/__tests__/results.test.ts +++ b/packages/autocomplete-preset-algolia/src/__tests__/results.test.ts @@ -139,7 +139,7 @@ describe('getAlgoliaHits', () => { }, }, ]); - expect(hits).toEqual([{ label: 'Hit 1' }, { label: 'Hit 2' }]); + expect(hits).toEqual([[{ label: 'Hit 1' }], [{ label: 'Hit 2' }]]); }); test('with custom search parameters', async () => { @@ -174,7 +174,7 @@ describe('getAlgoliaHits', () => { }, }, ]); - expect(hits).toEqual([{ label: 'Hit 1' }, { label: 'Hit 2' }]); + expect(hits).toEqual([[{ label: 'Hit 1' }], [{ label: 'Hit 2' }]]); }); test('attaches Algolia agent', async () => { diff --git a/packages/autocomplete-preset-algolia/src/results.ts b/packages/autocomplete-preset-algolia/src/results.ts index 09f46c2ca..c7706e175 100644 --- a/packages/autocomplete-preset-algolia/src/results.ts +++ b/packages/autocomplete-preset-algolia/src/results.ts @@ -1,5 +1,4 @@ import { HIGHLIGHT_PRE_TAG, HIGHLIGHT_POST_TAG } from './constants'; -import { flatten } from './utils'; import { version } from './version'; type SearchClient = any; @@ -57,7 +56,6 @@ export function getAlgoliaHits({ return getAlgoliaSource({ searchClient, queries }).then((response) => { const results = response.results; - // @TODO: should `getAlgoliaHits` flatten the hits? - return flatten(results.map((result) => result.hits)); + return results.map((result) => result.hits); }); } diff --git a/packages/autocomplete-preset-algolia/src/utils.ts b/packages/autocomplete-preset-algolia/src/utils.ts deleted file mode 100644 index a89dd6dda..000000000 --- a/packages/autocomplete-preset-algolia/src/utils.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function flatten(values: TType[]): TType[] { - return values.reduce((a, b) => { - return a.concat(b); - }, []); -}