|
1 | 1 | import { describe, it, expect } from 'vitest'; |
2 | | -import { buildAtomFeed } from './atom-builder'; |
| 2 | +import { buildAtomFeed, buildRssFeed } from './feed-builder'; |
3 | 3 |
|
4 | 4 | describe('buildAtomFeed', () => { |
5 | 5 | it('generates valid Atom XML with entries', () => { |
@@ -72,4 +72,56 @@ describe('buildAtomFeed', () => { |
72 | 72 | expect(xml).toContain('rel="self"'); |
73 | 73 | expect(xml).toContain('type="application/atom+xml"'); |
74 | 74 | }); |
| 75 | + |
| 76 | + it('includes WebSub hub link when provided', () => { |
| 77 | + const xml = buildAtomFeed({ |
| 78 | + id: 'https://example.com/atom.xml', |
| 79 | + title: 'Test', |
| 80 | + link: 'https://example.com', |
| 81 | + updated: '2026-03-29T10:00:00Z', |
| 82 | + entries: [], |
| 83 | + hubUrl: 'https://hub.example.com' |
| 84 | + }); |
| 85 | + |
| 86 | + expect(xml).toContain('rel="hub"'); |
| 87 | + expect(xml).toContain('https://hub.example.com'); |
| 88 | + }); |
| 89 | +}); |
| 90 | + |
| 91 | +describe('buildRssFeed', () => { |
| 92 | + it('generates valid RSS 2.0 XML', () => { |
| 93 | + const xml = buildRssFeed({ |
| 94 | + id: 'https://example.com/rss.xml', |
| 95 | + title: 'Test RSS', |
| 96 | + link: 'https://example.com', |
| 97 | + updated: '2026-03-29T10:00:00Z', |
| 98 | + entries: [{ |
| 99 | + id: 'https://example.com/diff/1', |
| 100 | + title: 'Content changed: Article', |
| 101 | + link: 'https://example.com/diff/1', |
| 102 | + updated: '2026-03-29T10:00:00Z', |
| 103 | + summary: 'Test summary' |
| 104 | + }] |
| 105 | + }); |
| 106 | + |
| 107 | + expect(xml).toContain('<rss version="2.0"'); |
| 108 | + expect(xml).toContain('<channel>'); |
| 109 | + expect(xml).toContain('<item>'); |
| 110 | + expect(xml).toContain('<pubDate>'); |
| 111 | + expect(xml).toContain('Test RSS'); |
| 112 | + }); |
| 113 | + |
| 114 | + it('includes WebSub hub in RSS', () => { |
| 115 | + const xml = buildRssFeed({ |
| 116 | + id: 'https://example.com/rss.xml', |
| 117 | + title: 'Test', |
| 118 | + link: 'https://example.com', |
| 119 | + updated: '2026-03-29T10:00:00Z', |
| 120 | + entries: [], |
| 121 | + hubUrl: 'https://hub.example.com' |
| 122 | + }); |
| 123 | + |
| 124 | + expect(xml).toContain('rel="hub"'); |
| 125 | + expect(xml).toContain('https://hub.example.com'); |
| 126 | + }); |
75 | 127 | }); |
0 commit comments