Skip to content

Commit b683d61

Browse files
committed
Remove invalid next test cases
1 parent dccf33f commit b683d61

File tree

1 file changed

+27
-93
lines changed

1 file changed

+27
-93
lines changed

packages/tests-unit/tests/adapters/cache.test.ts

Lines changed: 27 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -114,36 +114,48 @@ describe("S3Cache", () => {
114114
});
115115

116116
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 () => {
118118
await cache.get("key", { fetchCache: true });
119119

120120
expect(getFetchCacheSpy).toHaveBeenCalled();
121121
});
122122

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 () => {
124124
await cache.get("key", { kindHint: "fetch" });
125125

126126
expect(getFetchCacheSpy).toHaveBeenCalled();
127127
});
128128

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+
});
131133

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" });
133136

134-
expect(getFetchCacheSpy).toHaveBeenCalled();
135-
expect(result).toBeNull();
136-
});
137+
expect(getFetchCacheSpy).toHaveBeenCalled();
138+
});
137139

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);
142142

143-
const result = await cache.get("key", { kindHint: "fetch" });
143+
const result = await cache.get("key", { kind: "FETCH" });
144144

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+
});
147159
});
148160
});
149161

@@ -193,28 +205,6 @@ describe("S3Cache", () => {
193205
});
194206
});
195207

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-
218208
it("Should return base64 encoded value when cache data type is route and content is binary", async () => {
219209
incrementalCache.get.mockResolvedValueOnce({
220210
value: {
@@ -271,34 +261,6 @@ describe("S3Cache", () => {
271261
});
272262
});
273263

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-
302264
it("Should return value when cache data type is page", async () => {
303265
incrementalCache.get.mockResolvedValueOnce({
304266
value: {
@@ -326,34 +288,6 @@ describe("S3Cache", () => {
326288
});
327289
});
328290

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-
357291
it("Should return value when cache data type is redirect", async () => {
358292
incrementalCache.get.mockResolvedValueOnce({
359293
value: {

0 commit comments

Comments
 (0)