Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { DISCOVERY_LINK_HEADER, withDiscoveryLinks } from './discovery-links.ts'
4
5describe('discovery Link headers (task 10.2)', () => {
6 it('appends the Link header to HTML responses', () => {
7 const wrapped = withDiscoveryLinks(
8 new Response('<html></html>', {
9 headers: { 'Content-Type': 'text/html; charset=utf-8' },
10 }),
11 )
12 const link = wrapped.headers.get('link') ?? ''
13 expect(link).toBe(DISCOVERY_LINK_HEADER)
14 expect(link).toContain('</.well-known/api-catalog>; rel="api-catalog"')
15 expect(link).toContain('rel="service-desc"')
16 expect(link).toContain('rel="service-doc"')
17 })
18
19 it('leaves JSON responses untouched', () => {
20 const original = Response.json({ ok: true })
21 const wrapped = withDiscoveryLinks(original)
22 expect(wrapped).toBe(original)
23 expect(wrapped.headers.get('link')).toBeNull()
24 })
25})