@@ -28,7 +28,7 @@ describe('Snippet Browser test', () => {
2828 } ,
2929 } ,
3030 ] )
31- const snippeted = response . results [ 0 ] . hits [ 0 ] . _highlightResult
31+ const snippeted = response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult
3232 expect ( snippeted . overview . value ) . toEqual ( 'Princess' )
3333 const resKeys = Object . keys ( snippeted )
3434 expect ( resKeys ) . toEqual ( expect . arrayContaining ( Object . keys ( dataset [ 0 ] ) ) )
@@ -45,11 +45,11 @@ describe('Snippet Browser test', () => {
4545 } ,
4646 } ,
4747 ] )
48- const highlighted = response . results [ 0 ] . hits [ 0 ] . _highlightResult
48+ const highlighted = response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult
4949 const snippeted = response . results [ 0 ] . hits [ 0 ] . _snippetResult
5050 expect ( highlighted . overview . value ) . toEqual ( 'While' )
5151 expect ( snippeted . overview . value ) . toEqual ( 'While...' )
52- const resKeys = Object . keys ( response . results [ 0 ] . hits [ 0 ] . _highlightResult )
52+ const resKeys = Object . keys ( response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult )
5353
5454 expect ( resKeys ) . toEqual ( expect . arrayContaining ( Object . keys ( dataset [ 0 ] ) ) )
5555 } )
@@ -68,7 +68,7 @@ describe('Snippet Browser test', () => {
6868 } ,
6969 ] )
7070
71- const firstHitHighlight = response . results [ 0 ] . hits [ 0 ] . _highlightResult
71+ const firstHitHighlight = response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult
7272 const firstHitSnippet = response . results [ 0 ] . hits [ 0 ] . _snippetResult
7373
7474 expect ( firstHitHighlight . title . value ) . toEqual ( '<p>S</p>tar Wars' )
@@ -80,14 +80,14 @@ describe('Snippet Browser test', () => {
8080 'Luke <p>S</p>kywalker and...'
8181 )
8282
83- const secondHitHighlight = response . results [ 0 ] . hits [ 1 ] . _highlightResult
84- const secondHitSnippet = response . results [ 0 ] . hits [ 1 ] . _snippetResult
83+ const secondHitHighlight = response . results [ 0 ] ? .hits [ 1 ] ? ._highlightResult
84+ const secondHitSnippet = response . results [ 0 ] ? .hits [ 1 ] ? ._snippetResult
8585 expect ( secondHitHighlight . title . value ) . toEqual ( 'Four' )
8686 expect ( secondHitHighlight . overview . value ) . toEqual ( "It'<p>s</p> Ted" )
8787 expect ( secondHitSnippet . title . value ) . toEqual ( 'Four...' )
8888 expect ( secondHitSnippet . overview . value ) . toEqual ( "It'<p>s</p> Ted..." )
8989
90- const resKeys = Object . keys ( response . results [ 0 ] . hits [ 0 ] . _highlightResult )
90+ const resKeys = Object . keys ( response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult )
9191 expect ( resKeys ) . toEqual ( expect . arrayContaining ( Object . keys ( dataset [ 0 ] ) ) )
9292 } )
9393
@@ -102,10 +102,10 @@ describe('Snippet Browser test', () => {
102102 } ,
103103 ] )
104104
105- const firstHit = response . results [ 0 ] . hits [ 0 ] . _highlightResult
105+ const firstHit = response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult
106106 expect ( firstHit . overview . value ) . toEqual ( 'null' )
107107
108- const resKeys = Object . keys ( response . results [ 0 ] . hits [ 0 ] . _highlightResult )
108+ const resKeys = Object . keys ( response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult )
109109 expect ( resKeys ) . toEqual ( expect . arrayContaining ( Object . keys ( dataset [ 0 ] ) ) )
110110 } )
111111
@@ -119,7 +119,7 @@ describe('Snippet Browser test', () => {
119119 } ,
120120 } ,
121121 ] )
122- const snippeted = response . results [ 0 ] . hits [ 0 ] . _highlightResult
122+ const snippeted = response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult
123123 expect ( snippeted . overview . value ) . toEqual ( 'Princess' )
124124 const resKeys = Object . keys ( snippeted )
125125 expect ( resKeys ) . toEqual ( expect . arrayContaining ( Object . keys ( dataset [ 0 ] ) ) )
@@ -135,9 +135,9 @@ describe('Snippet Browser test', () => {
135135 } ,
136136 } ,
137137 ] )
138- const snippeted = response . results [ 0 ] . hits [ 0 ] . _highlightResult ?. overview
138+ const snippeted = response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult ?. overview
139139 expect ( snippeted . value ) . toEqual ( 'While' )
140- const resKeys = Object . keys ( response . results [ 0 ] . hits [ 0 ] . _highlightResult )
140+ const resKeys = Object . keys ( response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult )
141141 expect ( resKeys ) . toEqual ( expect . arrayContaining ( Object . keys ( dataset [ 0 ] ) ) )
142142 } )
143143
@@ -151,7 +151,7 @@ describe('Snippet Browser test', () => {
151151 } ,
152152 } ,
153153 ] )
154- const firstHit = response . results [ 0 ] . hits [ 0 ] . _highlightResult
154+ const firstHit = response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult
155155
156156 expect ( firstHit . title . value ) . toEqual (
157157 '__ais-highlight__S__/ais-highlight__tar Wars'
@@ -165,7 +165,7 @@ describe('Snippet Browser test', () => {
165165 "It'__ais-highlight__s__/ais-highlight__ Ted"
166166 )
167167
168- const resKeys = Object . keys ( response . results [ 0 ] . hits [ 0 ] . _highlightResult )
168+ const resKeys = Object . keys ( response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult )
169169 expect ( resKeys ) . toEqual ( expect . arrayContaining ( Object . keys ( dataset [ 0 ] ) ) )
170170 } )
171171
@@ -180,9 +180,9 @@ describe('Snippet Browser test', () => {
180180 } ,
181181 ] )
182182
183- const firstHit = response . results [ 0 ] . hits [ 0 ] . _highlightResult
183+ const firstHit = response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult
184184 expect ( firstHit . overview . value ) . toEqual ( 'null' )
185- const resKeys = Object . keys ( response . results [ 0 ] . hits [ 0 ] . _highlightResult )
185+ const resKeys = Object . keys ( response . results [ 0 ] ? .hits [ 0 ] ? ._highlightResult )
186186 expect ( resKeys ) . toEqual ( expect . arrayContaining ( Object . keys ( dataset [ 0 ] ) ) )
187187 } )
188188} )
0 commit comments