@@ -257,6 +257,65 @@ describe("Variant Analysis Monitor", () => {
257257 } ) ;
258258 } ) ;
259259
260+ describe ( "when the responses change" , ( ) => {
261+ let scannedRepos : ApiVariantAnalysisScannedRepository [ ] ;
262+
263+ beforeEach ( async ( ) => {
264+ scannedRepos = createMockScannedRepos ( [
265+ "pending" ,
266+ "in_progress" ,
267+ "in_progress" ,
268+ "in_progress" ,
269+ "pending" ,
270+ "pending" ,
271+ ] ) ;
272+ mockApiResponse = createMockApiResponse ( "in_progress" , scannedRepos ) ;
273+ mockGetVariantAnalysis . mockResolvedValueOnce ( mockApiResponse ) ;
274+
275+ let nextApiResponse = {
276+ ...mockApiResponse ,
277+ scanned_repositories : [ ...scannedRepos . map ( ( r ) => ( { ...r } ) ) ] ,
278+ } ;
279+ nextApiResponse . scanned_repositories [ 0 ] . analysis_status = "succeeded" ;
280+ nextApiResponse . scanned_repositories [ 1 ] . analysis_status = "succeeded" ;
281+ mockGetVariantAnalysis . mockResolvedValueOnce ( nextApiResponse ) ;
282+
283+ nextApiResponse = {
284+ ...mockApiResponse ,
285+ scanned_repositories : [
286+ ...nextApiResponse . scanned_repositories . map ( ( r ) => ( { ...r } ) ) ,
287+ ] ,
288+ } ;
289+ nextApiResponse . scanned_repositories [ 2 ] . analysis_status = "succeeded" ;
290+ nextApiResponse . scanned_repositories [ 5 ] . analysis_status = "succeeded" ;
291+ mockGetVariantAnalysis . mockResolvedValueOnce ( nextApiResponse ) ;
292+
293+ nextApiResponse = {
294+ ...mockApiResponse ,
295+ scanned_repositories : [
296+ ...nextApiResponse . scanned_repositories . map ( ( r ) => ( { ...r } ) ) ,
297+ ] ,
298+ } ;
299+ nextApiResponse . scanned_repositories [ 3 ] . analysis_status = "succeeded" ;
300+ nextApiResponse . scanned_repositories [ 4 ] . analysis_status = "failed" ;
301+ mockGetVariantAnalysis . mockResolvedValueOnce ( nextApiResponse ) ;
302+ } ) ;
303+
304+ it ( "should trigger a download extension command for each repo" , async ( ) => {
305+ const commandSpy = jest
306+ . spyOn ( commands , "executeCommand" )
307+ . mockResolvedValue ( undefined ) ;
308+
309+ await variantAnalysisMonitor . monitorVariantAnalysis (
310+ variantAnalysis ,
311+ cancellationTokenSource . token ,
312+ ) ;
313+
314+ expect ( mockGetVariantAnalysis ) . toBeCalledTimes ( 4 ) ;
315+ expect ( commandSpy ) . toBeCalledTimes ( 5 ) ;
316+ } ) ;
317+ } ) ;
318+
260319 describe ( "when there are no repos to scan" , ( ) => {
261320 beforeEach ( async ( ) => {
262321 scannedRepos = [ ] ;
0 commit comments