Skip to content

Commit

Permalink
fix(algolia): don't flatten getAlgoliaHits
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Sep 17, 2020
1 parent 042f4dc commit 8da805f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/autocomplete-preset-algolia/src/results.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { HIGHLIGHT_PRE_TAG, HIGHLIGHT_POST_TAG } from './constants';
import { flatten } from './utils';
import { version } from './version';

type SearchClient = any;
Expand Down Expand Up @@ -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);
});
}
5 changes: 0 additions & 5 deletions packages/autocomplete-preset-algolia/src/utils.ts

This file was deleted.

0 comments on commit 8da805f

Please sign in to comment.