forked from Lilly-Protocol/lily-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitemap.test.ts
More file actions
34 lines (29 loc) · 1.13 KB
/
Copy pathsitemap.test.ts
File metadata and controls
34 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { defaultSitemapUpdatedAt } from "@/config/routes";
import { getAbsoluteUrl, routes, siteConfig } from "@/config/site";
import sitemap from "./sitemap";
describe("sitemap", () => {
it("uses stable route dates across generations", () => {
const first = sitemap();
const second = sitemap();
expect(second).toEqual(first);
expect(first.every((entry) => entry.lastModified instanceof Date)).toBe(
true,
);
});
it("uses the home page updatedAt and a documented fallback", () => {
const entries = sitemap();
const homePage = siteConfig.pages.find((page) => page.path === routes.home);
const homeEntry = entries.find(
(entry) => entry.url === getAbsoluteUrl(routes.home),
);
const fallbackPage = siteConfig.pages.find((page) => !page.updatedAt);
const fallbackEntry = entries.find(
(entry) => entry.url === getAbsoluteUrl(fallbackPage!.path),
);
expect(homePage?.updatedAt).toBeDefined();
expect(homeEntry?.lastModified).toEqual(new Date(homePage!.updatedAt!));
expect(fallbackEntry?.lastModified).toEqual(
new Date(defaultSitemapUpdatedAt),
);
});
});