@@ -12,6 +12,13 @@ vi.mock("./cloudflare-context", () => ({
1212 } ) ,
1313} ) ) ;
1414
15+ const generateMessageBody = ( { host, url } : { host : string ; url : string } ) => ( {
16+ host,
17+ url,
18+ eTag : "etag" ,
19+ lastModified : Date . now ( ) ,
20+ } ) ;
21+
1522describe ( "MemoryQueue" , ( ) => {
1623 beforeAll ( ( ) => {
1724 vi . useFakeTimers ( ) ;
@@ -22,7 +29,7 @@ describe("MemoryQueue", () => {
2229
2330 it ( "should process revalidations for a path" , async ( ) => {
2431 const firstRequest = cache . send ( {
25- MessageBody : { host : "test.local" , url : "/test" } ,
32+ MessageBody : generateMessageBody ( { host : "test.local" , url : "/test" } ) ,
2633 MessageGroupId : generateMessageGroupId ( "/test" ) ,
2734 MessageDeduplicationId : "" ,
2835 } ) ;
@@ -31,7 +38,7 @@ describe("MemoryQueue", () => {
3138 expect ( mockServiceWorkerFetch ) . toHaveBeenCalledTimes ( 1 ) ;
3239
3340 const secondRequest = cache . send ( {
34- MessageBody : { host : "test.local" , url : "/test" } ,
41+ MessageBody : generateMessageBody ( { host : "test.local" , url : "/test" } ) ,
3542 MessageGroupId : generateMessageGroupId ( "/test" ) ,
3643 MessageDeduplicationId : "" ,
3744 } ) ;
@@ -42,7 +49,7 @@ describe("MemoryQueue", () => {
4249
4350 it ( "should process revalidations for multiple paths" , async ( ) => {
4451 const firstRequest = cache . send ( {
45- MessageBody : { host : "test.local" , url : "/test" } ,
52+ MessageBody : generateMessageBody ( { host : "test.local" , url : "/test" } ) ,
4653 MessageGroupId : generateMessageGroupId ( "/test" ) ,
4754 MessageDeduplicationId : "" ,
4855 } ) ;
@@ -51,7 +58,7 @@ describe("MemoryQueue", () => {
5158 expect ( mockServiceWorkerFetch ) . toHaveBeenCalledTimes ( 1 ) ;
5259
5360 const secondRequest = cache . send ( {
54- MessageBody : { host : "test.local" , url : "/test" } ,
61+ MessageBody : generateMessageBody ( { host : "test.local" , url : "/test" } ) ,
5562 MessageGroupId : generateMessageGroupId ( "/other" ) ,
5663 MessageDeduplicationId : "" ,
5764 } ) ;
@@ -63,12 +70,12 @@ describe("MemoryQueue", () => {
6370 it ( "should de-dupe revalidations" , async ( ) => {
6471 const requests = [
6572 cache . send ( {
66- MessageBody : { host : "test.local" , url : "/test" } ,
73+ MessageBody : generateMessageBody ( { host : "test.local" , url : "/test" } ) ,
6774 MessageGroupId : generateMessageGroupId ( "/test" ) ,
6875 MessageDeduplicationId : "" ,
6976 } ) ,
7077 cache . send ( {
71- MessageBody : { host : "test.local" , url : "/test" } ,
78+ MessageBody : generateMessageBody ( { host : "test.local" , url : "/test" } ) ,
7279 MessageGroupId : generateMessageGroupId ( "/test" ) ,
7380 MessageDeduplicationId : "" ,
7481 } ) ,
0 commit comments