1+ import { RETRY_COUNT_HEADER , calculateBackoffDelay , getRetryCount , shouldRetry } from "./retry.js" ;
12import { describe , expect , it } from "vitest" ;
23import type { Message } from "amqplib" ;
34import type { RetryPolicy } from "@amqp-contract/contract" ;
4- import {
5- RETRY_COUNT_HEADER ,
6- calculateBackoffDelay ,
7- getRetryCount ,
8- shouldRetry ,
9- } from "./retry.js" ;
105
116describe ( "Retry utilities" , ( ) => {
127 describe ( "getRetryCount" , ( ) => {
@@ -15,15 +10,15 @@ describe("Retry utilities", () => {
1510 properties : {
1611 headers : { } ,
1712 } ,
18- } as Message ;
13+ } as unknown as Message ;
1914
2015 expect ( getRetryCount ( msg ) ) . toBe ( 0 ) ;
2116 } ) ;
2217
2318 it ( "should return 0 when headers are undefined" , ( ) => {
2419 const msg = {
2520 properties : { } ,
26- } as Message ;
21+ } as unknown as Message ;
2722
2823 expect ( getRetryCount ( msg ) ) . toBe ( 0 ) ;
2924 } ) ;
@@ -35,7 +30,7 @@ describe("Retry utilities", () => {
3530 [ RETRY_COUNT_HEADER ] : 3 ,
3631 } ,
3732 } ,
38- } as Message ;
33+ } as unknown as Message ;
3934
4035 expect ( getRetryCount ( msg ) ) . toBe ( 3 ) ;
4136 } ) ;
@@ -47,7 +42,7 @@ describe("Retry utilities", () => {
4742 [ RETRY_COUNT_HEADER ] : "invalid" ,
4843 } ,
4944 } ,
50- } as Message ;
45+ } as unknown as Message ;
5146
5247 expect ( getRetryCount ( msg ) ) . toBe ( 0 ) ;
5348 } ) ;
@@ -59,7 +54,7 @@ describe("Retry utilities", () => {
5954 [ RETRY_COUNT_HEADER ] : - 1 ,
6055 } ,
6156 } ,
62- } as Message ;
57+ } as unknown as Message ;
6358
6459 expect ( getRetryCount ( msg ) ) . toBe ( 0 ) ;
6560 } ) ;
@@ -144,7 +139,7 @@ describe("Retry utilities", () => {
144139 [ RETRY_COUNT_HEADER ] : 100 ,
145140 } ,
146141 } ,
147- } as Message ;
142+ } as unknown as Message ;
148143
149144 const result = shouldRetry ( msg , undefined ) ;
150145
@@ -172,7 +167,7 @@ describe("Retry utilities", () => {
172167 [ RETRY_COUNT_HEADER ] : 1 ,
173168 } ,
174169 } ,
175- } as Message ;
170+ } as unknown as Message ;
176171
177172 const result = shouldRetry ( msg , policy ) ;
178173
@@ -194,7 +189,7 @@ describe("Retry utilities", () => {
194189 [ RETRY_COUNT_HEADER ] : 3 ,
195190 } ,
196191 } ,
197- } as Message ;
192+ } as unknown as Message ;
198193
199194 const result = shouldRetry ( msg , policy ) ;
200195
@@ -216,7 +211,7 @@ describe("Retry utilities", () => {
216211 [ RETRY_COUNT_HEADER ] : 5 ,
217212 } ,
218213 } ,
219- } as Message ;
214+ } as unknown as Message ;
220215
221216 const result = shouldRetry ( msg , policy ) ;
222217
@@ -243,7 +238,7 @@ describe("Retry utilities", () => {
243238 [ RETRY_COUNT_HEADER ] : 2 ,
244239 } ,
245240 } ,
246- } as Message ;
241+ } as unknown as Message ;
247242
248243 const result = shouldRetry ( msg , policy ) ;
249244
@@ -263,7 +258,7 @@ describe("Retry utilities", () => {
263258 properties : {
264259 headers : { } ,
265260 } ,
266- } as Message ;
261+ } as unknown as Message ;
267262
268263 const result = shouldRetry ( msg , policy ) ;
269264
0 commit comments