atom.test.ts 740 B

1234567891011121314151617
  1. import fs from 'fs';
  2. import { parseAtomFeed } from './atom';
  3. describe('Atom feed parser', () => {
  4. it('should successfully parse an atom feed', async () => {
  5. const atomFile = fs.readFileSync(`${__dirname}/fixtures/atom.xml`, 'utf8');
  6. const parsedFeed = parseAtomFeed(atomFile);
  7. expect(parsedFeed.items).toHaveLength(1);
  8. expect(parsedFeed.items[0].title).toBe('Why Testing Is The Best');
  9. expect(parsedFeed.items[0].link).toBe('https://www.example.com/2022/02/12/why-testing-is-the-best/');
  10. expect(parsedFeed.items[0].pubDate).toBe('2022-02-12T08:00:00+00:00');
  11. expect(parsedFeed.items[0].content).toMatch(
  12. /Testing is the best because it lets you know your code isn't broken, probably./
  13. );
  14. });
  15. });