-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitemap.test.ts
More file actions
56 lines (48 loc) · 1.65 KB
/
Copy pathsitemap.test.ts
File metadata and controls
56 lines (48 loc) · 1.65 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @vitest-environment node
import { describe, expect, it } from 'vitest';
import { getSortedFeedData } from '@/blog/services/post-repository';
import { SITE_URL } from '@/site/config/site';
import sitemap from './sitemap';
describe('sitemap', () => {
it('excludes private posts from sitemap entries', () => {
const entries = sitemap();
const urls = entries.map((entry) => entry.url);
const privatePosts = getSortedFeedData({ includePrivate: true }).filter(
(post) => post.visibility === 'private'
);
expect(urls).toContain(`${SITE_URL}/blog/ctr-pipeline`);
expect(privatePosts.length).toBeGreaterThan(0);
for (const post of privatePosts) {
expect(urls, `${post.slug} leaked to sitemap`).not.toContain(
`${SITE_URL}/blog/${post.slug}`
);
}
});
it('includes public hub routes for discovery', () => {
const entries = sitemap();
const urls = entries.map((entry) => entry.url);
expect(urls).toEqual(
expect.arrayContaining([
SITE_URL,
`${SITE_URL}/engineering`,
`${SITE_URL}/life`,
`${SITE_URL}/resume`,
`${SITE_URL}/rss.xml`,
])
);
expect(urls).not.toContain(`${SITE_URL}/blog`);
expect(urls).not.toContain(`${SITE_URL}/series`);
});
it('uses updated date for post lastModified when available', () => {
const entries = sitemap();
const publicUpdatedPost = getSortedFeedData().find((post) => post.updated);
if (!publicUpdatedPost) {
return;
}
expect(
entries.find(
(entry) => entry.url === `${SITE_URL}/blog/${publicUpdatedPost.slug}`
)?.lastModified
).toBe(publicUpdatedPost.updated);
});
});