From d597c7aa9c841e6b2b1ce584521b64a9774538c2 Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Tue, 22 Mar 2022 13:07:17 +0100 Subject: [PATCH] Test that ellipsis on smaller values than cropsize are not added --- tests/snippets.tests.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/snippets.tests.ts b/tests/snippets.tests.ts index bb44ffa2..a2962e01 100644 --- a/tests/snippets.tests.ts +++ b/tests/snippets.tests.ts @@ -308,3 +308,21 @@ describe('Snippet Browser test', () => { } }) }) + +test('Test attributes to snippet on value smaller than the snippet size', async () => { + const response = await searchClient.search([ + { + indexName: 'movies', + params: { + query: '', + attributesToSnippet: ['*:20'], + snippetEllipsisText: '...', + }, + }, + ]) + const hit = response.results[0].hits[0]._snippetResult + + if (hit?.overview) { + expect(hit?.title?.value).toEqual('Star Wars') + } +})