@@ -18,6 +18,7 @@ import * as sinon from 'sinon';
1818
1919import { ExponentialRetry } from '../src/exponential-retry' ;
2020import { Duration } from '../src/temporal' ;
21+ import { TestUtils } from './test-utils' ;
2122
2223// eslint-disable-next-line @typescript-eslint/no-explicit-any
2324function introspect ( obj : unknown ) : any {
@@ -52,27 +53,30 @@ describe('exponential retry class', () => {
5253 } ) ;
5354
5455 it ( 'makes the first callback' , ( ) => {
55- const clock = sandbox . useFakeTimers ( ) ;
56+ const clock = TestUtils . useFakeTimers ( sandbox ) ;
5657 const er = new ExponentialRetry < TestItem > (
5758 Duration . from ( { millis : 100 } ) ,
5859 Duration . from ( { millis : 1000 } ) ,
5960 ) ;
6061 sandbox . stub ( global . Math , 'random' ) . returns ( 0.75 ) ;
6162
6263 const item = makeItem ( ) ;
64+ let retried = false ;
6365 er . retryLater ( item , ( s : typeof item , t : Duration ) => {
6466 assert . strictEqual ( s , item ) ;
6567 assert . strictEqual ( t . totalOf ( 'millisecond' ) , 125 ) ;
68+ retried = true ;
6669 } ) ;
6770
6871 clock . tick ( 125 ) ;
6972
7073 const leftovers = er . close ( ) ;
74+ assert . strictEqual ( retried , true ) ;
7175 assert . strictEqual ( leftovers . length , 0 ) ;
7276 } ) ;
7377
7478 it ( 'closes gracefully' , ( ) => {
75- const clock = sandbox . useFakeTimers ( ) ;
79+ const clock = TestUtils . useFakeTimers ( sandbox ) ;
7680 const er = new ExponentialRetry < TestItem > (
7781 Duration . from ( { millis : 100 } ) ,
7882 Duration . from ( { millis : 1000 } ) ,
@@ -102,7 +106,7 @@ describe('exponential retry class', () => {
102106 } ) ;
103107
104108 it ( 'backs off exponentially' , ( ) => {
105- const clock = sandbox . useFakeTimers ( ) ;
109+ const clock = TestUtils . useFakeTimers ( sandbox ) ;
106110 const er = new ExponentialRetry < TestItem > (
107111 Duration . from ( { millis : 100 } ) ,
108112 Duration . from ( { millis : 1000 } ) ,
@@ -136,7 +140,7 @@ describe('exponential retry class', () => {
136140 } ) ;
137141
138142 it ( 'backs off exponentially until the max backoff' , ( ) => {
139- const clock = sandbox . useFakeTimers ( ) ;
143+ const clock = TestUtils . useFakeTimers ( sandbox ) ;
140144 const item = makeItem ( ) ;
141145 const er = new ExponentialRetry < TestItem > (
142146 Duration . from ( { millis : 100 } ) ,
@@ -170,7 +174,7 @@ describe('exponential retry class', () => {
170174 } ) ;
171175
172176 it ( 'calls retries in the right order' , ( ) => {
173- const clock = sandbox . useFakeTimers ( ) ;
177+ const clock = TestUtils . useFakeTimers ( sandbox ) ;
174178 const items = [ makeItem ( ) , makeItem ( ) ] ;
175179
176180 const er = new ExponentialRetry < TestItem > (
0 commit comments