rss.test.ts 657 B

123456789101112131415
  1. import fs from 'fs';
  2. import { parseRSSFeed } from './rss';
  3. describe('RSS feed parser', () => {
  4. it('should successfully parse an rss feed', async () => {
  5. const rssFile = fs.readFileSync(`${__dirname}/fixtures/rss.xml`, 'utf8');
  6. const parsedFeed = parseRSSFeed(rssFile);
  7. expect(parsedFeed.items).toHaveLength(1);
  8. expect(parsedFeed.items[0].title).toBe('A fake item');
  9. expect(parsedFeed.items[0].link).toBe('https://www.example.net/2022/02/10/something-fake/');
  10. expect(parsedFeed.items[0].pubDate).toBe('Thu, 10 Feb 2022 16:00:17 +0000');
  11. expect(parsedFeed.items[0].content).toBe('A description of a fake blog post');
  12. });
  13. });