full upgrade to dev

This commit is contained in:
2026-01-08 11:40:42 +01:00
parent 7320a0562d
commit 41f404c581
4 changed files with 48 additions and 28 deletions

View File

@@ -1,12 +1,38 @@
jest.mock("next/server", () => ({
NextResponse: jest.fn().mockImplementation(function (body, init) {
// Use function and assign to `this` so `new NextResponse(...)` returns an instance with properties
jest.mock("next/server", () => {
const mockNextResponse = function (
body: string | object,
init?: { headers?: Record<string, string> },
) {
// Return an object that mimics NextResponse
const mockResponse = {
body,
init,
text: async () => {
if (typeof body === "string") {
return body;
} else if (body && typeof body === "object") {
return JSON.stringify(body);
}
return "";
},
json: async () => {
if (typeof body === "object") {
return body;
}
try {
return JSON.parse(body as string);
} catch {
return {};
}
},
};
return mockResponse;
};
this.body = body;
this.init = init;
}),
}));
return {
NextResponse: mockNextResponse,
};
});
import { GET } from "@/app/api/sitemap/route";
@@ -81,18 +107,19 @@ describe("GET /api/sitemap", () => {
it("should return a sitemap", async () => {
const response = await GET();
expect(response.body).toContain(
// Get the body text from the NextResponse
const body = await response.text();
expect(body).toContain(
'<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">',
);
expect(response.body).toContain("<loc>https://dki.one/</loc>");
expect(response.body).toContain("<loc>https://dki.one/legal-notice</loc>");
expect(response.body).toContain(
"<loc>https://dki.one/privacy-policy</loc>",
);
expect(response.body).toContain(
expect(body).toContain("<loc>https://dki.one/</loc>");
expect(body).toContain("<loc>https://dki.one/legal-notice</loc>");
expect(body).toContain("<loc>https://dki.one/privacy-policy</loc>");
expect(body).toContain(
"<loc>https://dki.one/projects/just-doing-some-testing</loc>",
);
expect(response.body).toContain(
expect(body).toContain(
"<loc>https://dki.one/projects/blockchain-based-voting-system</loc>",
);
// Note: Headers are not available in test environment