42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import "@testing-library/jest-dom";
|
|
|
|
jest.mock("next/server", () => ({
|
|
NextResponse: jest.fn().mockImplementation((body: unknown, init?: ResponseInit) => {
|
|
const response = {
|
|
body,
|
|
init,
|
|
};
|
|
return response;
|
|
}),
|
|
}));
|
|
|
|
jest.mock("@/lib/sitemap", () => ({
|
|
getSitemapEntries: jest.fn(async () => [
|
|
{
|
|
url: "https://dki.one/en",
|
|
lastModified: "2025-01-01T00:00:00.000Z",
|
|
},
|
|
]),
|
|
generateSitemapXml: jest.fn(
|
|
() =>
|
|
'<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://dki.one/en</loc></url></urlset>',
|
|
),
|
|
}));
|
|
|
|
describe("Sitemap Component", () => {
|
|
beforeAll(() => {
|
|
process.env.NEXT_PUBLIC_BASE_URL = "https://dki.one";
|
|
});
|
|
|
|
it("should render the sitemap XML", async () => {
|
|
const { GET } = await import("@/app/sitemap.xml/route");
|
|
const response = await GET();
|
|
|
|
expect(response.body).toContain(
|
|
'<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">',
|
|
);
|
|
expect(response.body).toContain("<loc>https://dki.one/en</loc>");
|
|
// Note: Headers are not available in test environment
|
|
});
|
|
});
|