-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroute.test.ts
More file actions
48 lines (42 loc) · 1.29 KB
/
Copy pathroute.test.ts
File metadata and controls
48 lines (42 loc) · 1.29 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
import { beforeEach, describe, expect, it, vi } from 'vitest'
const blogMocks = vi.hoisted(() => ({
getVisibleBlogPosts: vi.fn()
}))
vi.mock('@/features/blog', () => blogMocks)
vi.mock('@/app/sitemap', () => ({
baseUrl: 'https://remcostoeten.nl'
}))
describe('rss route', () => {
beforeEach(() => {
vi.resetModules()
blogMocks.getVisibleBlogPosts.mockReset()
})
it('escapes xml content and returns the rss content type', async () => {
blogMocks.getVisibleBlogPosts.mockResolvedValue([
{
slug: 'engineering/escape-test',
metadata: {
title: 'Hello & Goodbye',
summary: '2 < 3 and "quotes" too',
publishedAt: '2026-04-07',
draft: false
}
}
])
const { GET } = await import('@/app/(marketing)/rss/route')
const response = await GET()
const body = await response.text()
expect(blogMocks.getVisibleBlogPosts).toHaveBeenCalledTimes(1)
expect(response.headers.get('content-type')).toBe(
'application/rss+xml; charset=utf-8'
)
expect(body).toContain('<title>Hello & Goodbye</title>')
expect(body).toContain(
'<description>2 < 3 and "quotes" too</description>'
)
expect(body).toContain(
'<link>https://remcostoeten.nl/blog/engineering/escape-test</link>'
)
expect(body).not.toContain('<title>Hello & Goodbye</title>')
})
})