@@ -114,36 +114,48 @@ describe("S3Cache", () => {
114
114
} ) ;
115
115
116
116
describe ( "fetch cache" , ( ) => {
117
- it ( "Should retrieve cache from fetch cache when fetch cache is true" , async ( ) => {
117
+ it ( "Should retrieve cache from fetch cache when fetch cache is true (next 13.5+) " , async ( ) => {
118
118
await cache . get ( "key" , { fetchCache : true } ) ;
119
119
120
120
expect ( getFetchCacheSpy ) . toHaveBeenCalled ( ) ;
121
121
} ) ;
122
122
123
- it ( "Should retrieve cache from fetch cache when hint is fetch" , async ( ) => {
123
+ it ( "Should retrieve cache from fetch cache when hint is fetch (next14) " , async ( ) => {
124
124
await cache . get ( "key" , { kindHint : "fetch" } ) ;
125
125
126
126
expect ( getFetchCacheSpy ) . toHaveBeenCalled ( ) ;
127
127
} ) ;
128
128
129
- it ( "Should return null when tag cache last modified is -1" , async ( ) => {
130
- tagCache . getLastModified . mockResolvedValueOnce ( - 1 ) ;
129
+ describe ( "next15" , ( ) => {
130
+ beforeEach ( ( ) => {
131
+ globalThis . isNextAfter15 = true ;
132
+ } ) ;
131
133
132
- const result = await cache . get ( "key" , { kindHint : "fetch" } ) ;
134
+ it ( "Should retrieve cache from fetch cache when hint is fetch" , async ( ) => {
135
+ await cache . get ( "key" , { kind : "FETCH" } ) ;
133
136
134
- expect ( getFetchCacheSpy ) . toHaveBeenCalled ( ) ;
135
- expect ( result ) . toBeNull ( ) ;
136
- } ) ;
137
+ expect ( getFetchCacheSpy ) . toHaveBeenCalled ( ) ;
138
+ } ) ;
137
139
138
- it ( "Should return null when incremental cache throws" , async ( ) => {
139
- incrementalCache . get . mockRejectedValueOnce (
140
- new Error ( "Error retrieving cache" ) ,
141
- ) ;
140
+ it ( "Should return null when tag cache last modified is -1" , async ( ) => {
141
+ tagCache . getLastModified . mockResolvedValueOnce ( - 1 ) ;
142
142
143
- const result = await cache . get ( "key" , { kindHint : "fetch " } ) ;
143
+ const result = await cache . get ( "key" , { kind : "FETCH " } ) ;
144
144
145
- expect ( getFetchCacheSpy ) . toHaveBeenCalled ( ) ;
146
- expect ( result ) . toBeNull ( ) ;
145
+ expect ( getFetchCacheSpy ) . toHaveBeenCalled ( ) ;
146
+ expect ( result ) . toBeNull ( ) ;
147
+ } ) ;
148
+
149
+ it ( "Should return null when incremental cache throws" , async ( ) => {
150
+ incrementalCache . get . mockRejectedValueOnce (
151
+ new Error ( "Error retrieving cache" ) ,
152
+ ) ;
153
+
154
+ const result = await cache . get ( "key" , { kind : "FETCH" } ) ;
155
+
156
+ expect ( getFetchCacheSpy ) . toHaveBeenCalled ( ) ;
157
+ expect ( result ) . toBeNull ( ) ;
158
+ } ) ;
147
159
} ) ;
148
160
} ) ;
149
161
@@ -193,28 +205,6 @@ describe("S3Cache", () => {
193
205
} ) ;
194
206
} ) ;
195
207
196
- it ( "Should return value when cache data type is route for next 15 and later" , async ( ) => {
197
- incrementalCache . get . mockResolvedValueOnce ( {
198
- value : {
199
- type : "route" ,
200
- body : "{}" ,
201
- } ,
202
- lastModified : Date . now ( ) ,
203
- } ) ;
204
- globalThis . isNextAfter15 = true ;
205
-
206
- const result = await cache . get ( "key" , { kindHint : "app" } ) ;
207
-
208
- expect ( getIncrementalCache ) . toHaveBeenCalled ( ) ;
209
- expect ( result ) . toEqual ( {
210
- value : {
211
- kind : "APP_ROUTE" ,
212
- body : Buffer . from ( "{}" ) ,
213
- } ,
214
- lastModified : Date . now ( ) ,
215
- } ) ;
216
- } ) ;
217
-
218
208
it ( "Should return base64 encoded value when cache data type is route and content is binary" , async ( ) => {
219
209
incrementalCache . get . mockResolvedValueOnce ( {
220
210
value : {
@@ -271,34 +261,6 @@ describe("S3Cache", () => {
271
261
} ) ;
272
262
} ) ;
273
263
274
- it ( "Should return value when cache data type is app for next 15 and later" , async ( ) => {
275
- incrementalCache . get . mockResolvedValueOnce ( {
276
- value : {
277
- type : "app" ,
278
- html : "<html></html>" ,
279
- rsc : "rsc" ,
280
- meta : {
281
- status : 200 ,
282
- } ,
283
- } ,
284
- lastModified : Date . now ( ) ,
285
- } ) ;
286
- globalThis . isNextAfter15 = true ;
287
-
288
- const result = await cache . get ( "key" , { kindHint : "app" } ) ;
289
-
290
- expect ( getIncrementalCache ) . toHaveBeenCalled ( ) ;
291
- expect ( result ) . toEqual ( {
292
- value : {
293
- kind : "APP_PAGE" ,
294
- html : "<html></html>" ,
295
- rscData : Buffer . from ( "rsc" ) ,
296
- status : 200 ,
297
- } ,
298
- lastModified : Date . now ( ) ,
299
- } ) ;
300
- } ) ;
301
-
302
264
it ( "Should return value when cache data type is page" , async ( ) => {
303
265
incrementalCache . get . mockResolvedValueOnce ( {
304
266
value : {
@@ -326,34 +288,6 @@ describe("S3Cache", () => {
326
288
} ) ;
327
289
} ) ;
328
290
329
- it ( "Should return value when cache data type is page for next15 and later" , async ( ) => {
330
- incrementalCache . get . mockResolvedValueOnce ( {
331
- value : {
332
- type : "page" ,
333
- html : "<html></html>" ,
334
- json : { } ,
335
- meta : {
336
- status : 200 ,
337
- } ,
338
- } ,
339
- lastModified : Date . now ( ) ,
340
- } ) ;
341
- globalThis . isNextAfter15 = true ;
342
-
343
- const result = await cache . get ( "key" , { kindHint : "pages" } ) ;
344
-
345
- expect ( getIncrementalCache ) . toHaveBeenCalled ( ) ;
346
- expect ( result ) . toEqual ( {
347
- value : {
348
- kind : "PAGES" ,
349
- html : "<html></html>" ,
350
- pageData : { } ,
351
- status : 200 ,
352
- } ,
353
- lastModified : Date . now ( ) ,
354
- } ) ;
355
- } ) ;
356
-
357
291
it ( "Should return value when cache data type is redirect" , async ( ) => {
358
292
incrementalCache . get . mockResolvedValueOnce ( {
359
293
value : {
0 commit comments