Skip to content

Commit 4ec543f

Browse files
committed
Add with query facet tests
1 parent e1a9a6d commit 4ec543f

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

tests/facets.tests.ts

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Instant MeiliSearch Browser test', () => {
1818
)
1919
})
2020

21-
test('Test one facet on facetsFilters', async () => {
21+
test('Test one facet on facetsFilters without a query', async () => {
2222
const response = await searchClient.search([
2323
{
2424
indexName: 'movies',
@@ -33,7 +33,22 @@ describe('Instant MeiliSearch Browser test', () => {
3333
expect(hits[0].title).toEqual('Star Wars')
3434
})
3535

36-
test('Test multiple on facetsFilters', async () => {
36+
test('Test one facet on facetsFilters with a query', async () => {
37+
const response = await searchClient.search([
38+
{
39+
indexName: 'movies',
40+
params: {
41+
query: 'four',
42+
facetFilters: ['genres:Crime'],
43+
},
44+
},
45+
])
46+
const hits = response.results[0].hits
47+
expect(hits.length).toEqual(2)
48+
expect(hits[0].title).toEqual('Four Rooms')
49+
})
50+
51+
test('Test multiple on facetsFilters without a query', async () => {
3752
const response = await searchClient.search([
3853
{
3954
indexName: 'movies',
@@ -48,7 +63,35 @@ describe('Instant MeiliSearch Browser test', () => {
4863
expect(hits[0].title).toEqual('Ariel')
4964
})
5065

51-
test('Test multiple nested on facetsFilters', async () => {
66+
test('Test multiple on facetsFilters with a query', async () => {
67+
const response = await searchClient.search([
68+
{
69+
indexName: 'movies',
70+
params: {
71+
query: 'ar',
72+
facetFilters: ['genres:Comedy', 'genres:Crime'],
73+
},
74+
},
75+
])
76+
const hits = response.results[0].hits
77+
expect(hits.length).toEqual(2)
78+
expect(hits[0].title).toEqual('Ariel')
79+
})
80+
81+
test('Test multiple nested on facetsFilters without a query', async () => {
82+
const params = {
83+
indexName: 'movies',
84+
params: {
85+
query: 'night',
86+
facetFilters: [['genres:action', 'genres:Thriller'], 'genres:crime'],
87+
},
88+
}
89+
const response = await searchClient.search([params])
90+
const hits = response.results[0].hits
91+
expect(hits[0].title).toEqual('Judgment Night')
92+
})
93+
94+
test('Test multiple nested on facetsFilters with a query', async () => {
5295
const params = {
5396
indexName: 'movies',
5497
params: {

0 commit comments

Comments
 (0)