@@ -254,20 +254,30 @@ describe('query-results', () => {
254254 } ) ;
255255
256256 describe ( 'splat and slurp' , ( ) => {
257- it ( 'should splat and slurp query history' , async ( ) => {
258- const infoSuccessRaw = createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( `${ queryPath } -a` , false , false , '/a/b/c/a' , false ) ) ;
259- const infoSuccessInterpreted = createMockFullQueryInfo ( 'b' , createMockQueryWithResults ( `${ queryPath } -b` , true , true , '/a/b/c/b' , false ) ) ;
260- const infoEarlyFailure = createMockFullQueryInfo ( 'c' , undefined , true ) ;
261- const infoLateFailure = createMockFullQueryInfo ( 'd' , createMockQueryWithResults ( `${ queryPath } -c` , false , false , '/a/b/c/d' , false ) ) ;
262- const infoInprogress = createMockFullQueryInfo ( 'e' ) ;
263- const allHistory = [
257+
258+ let infoSuccessRaw : LocalQueryInfo ;
259+ let infoSuccessInterpreted : LocalQueryInfo ;
260+ let infoEarlyFailure : LocalQueryInfo ;
261+ let infoLateFailure : LocalQueryInfo ;
262+ let infoInprogress : LocalQueryInfo ;
263+ let allHistory : LocalQueryInfo [ ] ;
264+
265+ beforeEach ( ( ) => {
266+ infoSuccessRaw = createMockFullQueryInfo ( 'a' , createMockQueryWithResults ( `${ queryPath } -a` , false , false , '/a/b/c/a' , false ) ) ;
267+ infoSuccessInterpreted = createMockFullQueryInfo ( 'b' , createMockQueryWithResults ( `${ queryPath } -b` , true , true , '/a/b/c/b' , false ) ) ;
268+ infoEarlyFailure = createMockFullQueryInfo ( 'c' , undefined , true ) ;
269+ infoLateFailure = createMockFullQueryInfo ( 'd' , createMockQueryWithResults ( `${ queryPath } -c` , false , false , '/a/b/c/d' , false ) ) ;
270+ infoInprogress = createMockFullQueryInfo ( 'e' ) ;
271+ allHistory = [
264272 infoSuccessRaw ,
265273 infoSuccessInterpreted ,
266274 infoEarlyFailure ,
267275 infoLateFailure ,
268276 infoInprogress
269277 ] ;
278+ } ) ;
270279
280+ it ( 'should splat and slurp query history' , async ( ) => {
271281 // the expected results only contains the history with completed queries
272282 const expectedHistory = [
273283 infoSuccessRaw ,
@@ -313,6 +323,18 @@ describe('query-results', () => {
313323 }
314324 expect ( allHistoryActual . length ) . to . deep . eq ( expectedHistory . length ) ;
315325 } ) ;
326+
327+ it ( 'should handle an invalid query history version' , async ( ) => {
328+ const badPath = path . join ( tmpDir . name , 'bad-query-history.json' ) ;
329+ fs . writeFileSync ( badPath , JSON . stringify ( {
330+ version : 2 ,
331+ queries : allHistory
332+ } ) , 'utf8' ) ;
333+
334+ const allHistoryActual = await slurpQueryHistory ( badPath , mockConfig ) ;
335+ // version number is invalid. Should return an empty array.
336+ expect ( allHistoryActual ) . to . deep . eq ( [ ] ) ;
337+ } ) ;
316338 } ) ;
317339
318340 function createMockQueryWithResults (
0 commit comments