Skip to content

Commit f0ac9db

Browse files
authored
Add tests on facetfilter with spaces (#461)
1 parent 6a7c074 commit f0ac9db

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/search_tests.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const dataset = [
4444
id: 1344,
4545
title: 'The Hobbit',
4646
comment: 'An awesome book',
47-
genre: 'adventure',
47+
genre: 'sci fi',
4848
},
4949
{
5050
id: 4,
@@ -299,14 +299,26 @@ describe.each([
299299
})
300300
.then((response: Types.SearchResponse) => {
301301
expect(response).toHaveProperty('facetsDistribution', {
302-
genre: { adventure: 0, fantasy: 0, romance: 2 },
302+
genre: { adventure: 0, fantasy: 0, romance: 2, "sci fi": 0, },
303303
})
304304
expect(response).toHaveProperty('exhaustiveFacetsCount', true)
305305
expect(response).toHaveProperty('hits', expect.any(Array))
306306
expect(response.hits.length).toEqual(2)
307307
})
308308
})
309309

310+
test(`${permission} key: Search with facetFilters with spaces`, async () => {
311+
await client
312+
.getIndex(index.uid)
313+
.search('h', {
314+
facetFilters: ['genre:sci fi'],
315+
})
316+
.then((response: Types.SearchResponse) => {
317+
expect(response).toHaveProperty('hits', expect.any(Array))
318+
expect(response.hits.length).toEqual(1)
319+
})
320+
})
321+
310322
test(`${permission} key: Search with multiple facetFilters`, async () => {
311323
await client
312324
.getIndex(index.uid)
@@ -316,7 +328,7 @@ describe.each([
316328
})
317329
.then((response: Types.SearchResponse) => {
318330
expect(response).toHaveProperty('facetsDistribution', {
319-
genre: { adventure: 0, fantasy: 0, romance: 2 },
331+
genre: { adventure: 0, fantasy: 0, romance: 2, "sci fi": 0, },
320332
})
321333
expect(response).toHaveProperty('exhaustiveFacetsCount', true)
322334
expect(response).toHaveProperty('hits', expect.any(Array))

0 commit comments

Comments
 (0)