@@ -9,15 +9,16 @@ import { StandardRetryStrategy } from "./StandardRetryStrategy";
9
9
10
10
jest . mock ( "./StandardRetryStrategy" ) ;
11
11
12
- describe ( "resolveRetryConfig" , ( ) => {
12
+ describe ( resolveRetryConfig . name , ( ) => {
13
+ const retryModeProvider = jest . fn ( ) ;
13
14
afterEach ( ( ) => {
14
15
jest . clearAllMocks ( ) ;
15
16
} ) ;
16
17
17
18
describe ( "maxAttempts" , ( ) => {
18
19
it ( "assigns maxAttempts value if present" , async ( ) => {
19
20
for ( const maxAttempts of [ 1 , 2 , 3 ] ) {
20
- const output = await resolveRetryConfig ( { maxAttempts } ) . maxAttempts ( ) ;
21
+ const output = await resolveRetryConfig ( { maxAttempts, retryModeProvider } ) . maxAttempts ( ) ;
21
22
expect ( output ) . toStrictEqual ( maxAttempts ) ;
22
23
}
23
24
} ) ;
@@ -29,21 +30,28 @@ describe("resolveRetryConfig", () => {
29
30
retry : jest . fn ( ) ,
30
31
} ;
31
32
const { retryStrategy } = resolveRetryConfig ( {
33
+ retryModeProvider,
32
34
retryStrategy : mockRetryStrategy ,
33
35
} ) ;
34
- expect ( retryStrategy ) . toEqual ( mockRetryStrategy ) ;
36
+ expect ( retryStrategy ( ) ) . resolves . toEqual ( mockRetryStrategy ) ;
35
37
} ) ;
36
38
37
- describe ( "creates StandardRetryStrategy if retryStrategy not present" , ( ) => {
38
- describe ( "passes maxAttempts if present" , ( ) => {
39
- for ( const maxAttempts of [ 1 , 2 , 3 ] ) {
40
- it ( `when maxAttempts=${ maxAttempts } ` , async ( ) => {
41
- resolveRetryConfig ( { maxAttempts } ) ;
42
- expect ( StandardRetryStrategy as jest . Mock ) . toHaveBeenCalledTimes ( 1 ) ;
43
- const output = await ( StandardRetryStrategy as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ( ) ;
44
- expect ( output ) . toStrictEqual ( maxAttempts ) ;
39
+ describe ( "creates RetryStrategy if retryStrategy not present" , ( ) => {
40
+ describe ( "StandardRetryStrategy" , ( ) => {
41
+ describe ( "when retryMode=standard" , ( ) => {
42
+ describe ( "passes maxAttempts if present" , ( ) => {
43
+ const retryMode = "standard" ;
44
+ for ( const maxAttempts of [ 1 , 2 , 3 ] ) {
45
+ it ( `when maxAttempts=${ maxAttempts } ` , async ( ) => {
46
+ const { retryStrategy } = resolveRetryConfig ( { maxAttempts, retryMode, retryModeProvider } ) ;
47
+ await retryStrategy ( ) ;
48
+ expect ( StandardRetryStrategy as jest . Mock ) . toHaveBeenCalledTimes ( 1 ) ;
49
+ const output = await ( StandardRetryStrategy as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ( ) ;
50
+ expect ( output ) . toStrictEqual ( maxAttempts ) ;
51
+ } ) ;
52
+ }
45
53
} ) ;
46
- }
54
+ } ) ;
47
55
} ) ;
48
56
} ) ;
49
57
} ) ;
0 commit comments