@@ -49,6 +49,43 @@ describe('Snippet Browser test', () => {
4949 expect ( snippeted ?. overview ?. value ) . toEqual ( 'While...' )
5050 } )
5151
52+ test ( 'Test * attributesToSnippet on specific query' , async ( ) => {
53+ const response = await searchClient . search < Movies > ( [
54+ {
55+ indexName : 'movies' ,
56+ params : {
57+ query : 'judg' ,
58+ attributesToSnippet : [ '*:2' ] ,
59+ snippetEllipsisText : '...' ,
60+ } ,
61+ } ,
62+ ] )
63+ const highlighted = response . results [ 0 ] ?. hits [ 0 ] ?. _highlightResult
64+ const snippeted = response . results [ 0 ] . hits [ 0 ] . _snippetResult
65+ expect ( highlighted ?. id ?. value ) . toEqual ( '6' )
66+ expect ( highlighted ?. title ?. value ) . toEqual ( '__ais-highlight__Judg__/ais-highlight__ment Night' )
67+ expect ( highlighted ?. overview ?. value ) . toEqual ( 'While' )
68+ // requires HightlightResult to include Array types
69+ // expect(highlighted?.genres?.value).toEqual(
70+ // `[
71+ // "Action",
72+ // "Thriller",
73+ // "Crime"
74+ // ]`)
75+ expect ( highlighted ?. release_date ?. value ) . toEqual ( '750643200' )
76+ expect ( snippeted ?. id ?. value ) . toEqual ( '6' )
77+ expect ( snippeted ?. title ?. value ) . toEqual ( '__ais-highlight__Judg__/ais-highlight__ment Night...' )
78+ expect ( snippeted ?. overview ?. value ) . toEqual ( 'While...' )
79+ // requires SnippetResult to include Array types
80+ // expect(snippeted?.genres?.value).toEqual(
81+ // `[
82+ // "Action",
83+ // "Thriller",
84+ // "Crime"
85+ // ]`)
86+ expect ( snippeted ?. release_date ?. value ) . toEqual ( '750643200' )
87+ } )
88+
5289 test ( 'Test two attributesToSnippet on specific query with one hit empty string' , async ( ) => {
5390 const response = await searchClient . search < Movies > ( [
5491 {
0 commit comments