feat(search-backend-module-es): test error handling

Co-authored-by: Emma Indal <emma.indahl@gmail.com>
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2022-06-28 13:46:13 +02:00
parent 369a920595
commit 19bcc9d795
@@ -793,6 +793,29 @@ describe('ElasticSearchSearchEngine', () => {
elasticSearchQuerySpy.mockClear();
});
it('should throws missing index error', async () => {
jest.spyOn(clientWrapper, 'search').mockRejectedValue({
meta: {
body: {
error: {
type: 'index_not_found_exception',
},
},
},
});
await expect(
async () =>
await testSearchEngine.query({
term: 'testTerm',
types: ['unknown'],
filters: {},
}),
).rejects.toThrow(
'Missing index for unknown__search. This means there are no documents to search through',
);
});
});
describe('indexer', () => {