@@ -553,14 +553,17 @@ describe('exists', () => {
553553describe ( 'download' , ( ) => {
554554 let originalFetch ;
555555 let tempDir ;
556+ let warnSpy ;
556557
557558 beforeEach ( ( ) => {
558559 originalFetch = globalThis . fetch ;
559560 tempDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'spm-download-' ) ) ;
561+ warnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
560562 } ) ;
561563
562564 afterEach ( ( ) => {
563565 globalThis . fetch = originalFetch ;
566+ warnSpy . mockRestore ( ) ;
564567 fs . rmSync ( tempDir , { recursive : true , force : true } ) ;
565568 } ) ;
566569
@@ -596,9 +599,19 @@ describe('download', () => {
596599 . mockResolvedValueOnce ( downloadResponse ( 'complete' ) ) ;
597600 const destination = path . join ( tempDir , 'artifact.tar.gz' ) ;
598601
599- await download ( 'https://example/artifact.tar.gz' , destination , ( ) => { } ) ;
602+ const pending = download (
603+ 'https://example/artifact.tar.gz' ,
604+ destination ,
605+ ( ) => { } ,
606+ ) ;
607+ await jest . advanceTimersByTimeAsync ( 1_500 ) ;
608+ await pending ;
600609
601610 expect ( globalThis . fetch ) . toHaveBeenCalledTimes ( 2 ) ;
611+ expect ( warnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
612+ expect ( warnSpy ) . toHaveBeenCalledWith (
613+ expect . stringContaining ( 'retrying in 1000ms' ) ,
614+ ) ;
602615 expect ( fs . readFileSync ( destination , 'utf8' ) ) . toBe ( 'complete' ) ;
603616 expect ( fs . existsSync ( `${ destination } .download` ) ) . toBe ( false ) ;
604617 } ) ;
@@ -621,6 +634,10 @@ describe('download', () => {
621634 await pending ;
622635
623636 expect ( globalThis . fetch ) . toHaveBeenCalledTimes ( 2 ) ;
637+ expect ( warnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
638+ expect ( warnSpy ) . toHaveBeenCalledWith (
639+ expect . stringContaining ( 'retrying in 1000ms' ) ,
640+ ) ;
624641 expect ( fs . readFileSync ( destination , 'utf8' ) ) . toBe ( 'complete' ) ;
625642 expect ( fs . existsSync ( `${ destination } .download` ) ) . toBe ( false ) ;
626643 } finally {
@@ -643,6 +660,7 @@ describe('download', () => {
643660 ) . rejects . toThrow ( / H T T P 4 0 4 / ) ;
644661
645662 expect ( globalThis . fetch ) . toHaveBeenCalledTimes ( 1 ) ;
663+ expect ( warnSpy ) . not . toHaveBeenCalled ( ) ;
646664 expect ( fs . existsSync ( destination ) ) . toBe ( false ) ;
647665 } ) ;
648666} ) ;
0 commit comments