Skip to content

Commit fe0e219

Browse files
jezzzmStrift
authored andcommitted
chore: add test
1 parent db9b5b8 commit fe0e219

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

packages/autocomplete-client/__tests__/test.utils.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export const MOVIES = [
2626
genres: ['Drama', 'Crime', 'Comedy'],
2727
poster: 'https://image.tmdb.org/t/p/w500/ojDg0PGvs6R9xYFodRct2kdI6wC.jpg',
2828
release_date: 593395200,
29+
reviews: [
30+
{ id: 1, author: 'John', content: 'one star' },
31+
{ id: 2, author: 'Jane', content: 'two stars' },
32+
],
2933
},
3034
{
3135
id: 5,
@@ -35,6 +39,10 @@ export const MOVIES = [
3539
genres: ['Crime', 'Comedy'],
3640
poster: 'https://image.tmdb.org/t/p/w500/75aHn1NOYXh4M7L5shoeQ6NGykP.jpg',
3741
release_date: 818467200,
42+
reviews: [
43+
{ id: 3, author: 'John', content: 'three stars' },
44+
{ id: 4, author: 'Jane', content: 'four stars' },
45+
],
3846
},
3947
{
4048
id: 6,
@@ -44,6 +52,10 @@ export const MOVIES = [
4452
genres: ['Action', 'Thriller', 'Crime'],
4553
poster: 'https://image.tmdb.org/t/p/w500/rYFAvSPlQUCebayLcxyK79yvtvV.jpg',
4654
release_date: 750643200,
55+
reviews: [
56+
{ id: 5, author: 'John', content: 'five stars' },
57+
{ id: 6, author: 'Jane', content: 'six stars' },
58+
],
4759
},
4860
{
4961
id: 11,
@@ -53,6 +65,10 @@ export const MOVIES = [
5365
genres: ['Adventure', 'Action', 'Science Fiction'],
5466
poster: 'https://image.tmdb.org/t/p/w500/6FfCtAuVAW8XJjZ7eWeLibRLWTw.jpg',
5567
release_date: 233366400,
68+
reviews: [
69+
{ id: 7, author: 'John', content: 'seven stars' },
70+
{ id: 8, author: 'Jane', content: 'eight stars' },
71+
],
5672
},
5773
{
5874
id: 30,
@@ -61,6 +77,10 @@ export const MOVIES = [
6177
genres: ['Animation', 'Science Fiction'],
6278
poster: 'https://image.tmdb.org/t/p/w500/gSuHDeWemA1menrwfMRChnSmMVN.jpg',
6379
release_date: 819676800,
80+
reviews: [
81+
{ id: 9, author: 'John', content: 'nine stars' },
82+
{ id: 10, author: 'Jane', content: 'ten stars' },
83+
],
6484
},
6585
{
6686
id: 24,
@@ -69,6 +89,10 @@ export const MOVIES = [
6989
genres: ['Action', 'Crime'],
7090
poster: 'https://image.tmdb.org/t/p/w500/v7TaX8kXMXs5yFFGR41guUDNcnB.jpg',
7191
release_date: 1065744000,
92+
reviews: [
93+
{ id: 11, author: 'John', content: 'eleven stars' },
94+
{ id: 12, author: 'Jane', content: 'twelve stars' },
95+
],
7296
},
7397
]
7498

packages/autocomplete-client/src/search/__tests__/fetchMeilisearchResults.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,19 @@ describe('fetchMeilisearchResults', () => {
184184
matchedWords: [],
185185
})
186186
})
187+
188+
test('highlight results skips attributes missing value key', async () => {
189+
const results = await fetchMeilisearchResults({
190+
searchClient,
191+
queries: [
192+
{
193+
indexName: INDEX_NAME,
194+
query: 'kill bill',
195+
},
196+
],
197+
})
198+
console.log(results.map((r) => r.hits))
199+
200+
expect(results[0].hits[0]._highlightResult?.reviews).toEqual(undefined)
201+
})
187202
})

0 commit comments

Comments
 (0)