aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/helpers/rss.test.ts
blob: b04f6d3c967ab4ff7dbefa16d3ca2762d53dfafc (plain)
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
import { describe, expect, it } from '@jest/globals';
import { CONFIG } from '../config';
import { ROUTES } from '../constants';
import { generateFeed } from './rss';

describe('generate-feed', () => {
  /* eslint-disable max-statements */
  it('generates a rss feed', async () => {
    const feed = await generateFeed();

    // eslint-disable-next-line @typescript-eslint/no-magic-numbers
    expect.assertions(10);

    expect(feed.options.author).toStrictEqual({
      name: CONFIG.name,
      email: process.env.APP_AUTHOR_EMAIL,
      link: CONFIG.url,
    });
    expect(feed.options.copyright).toBe(
      `\u00A9 ${CONFIG.copyright.startYear} - ${CONFIG.copyright.endYear} ${CONFIG.name} - CC BY SA`
    );
    expect(feed.options.description).toBe(process.env.APP_FEED_DESCRIPTION);
    expect(feed.options.favicon).toBe(`${CONFIG.url}/favicon.ico`);
    expect(feed.options.feedLinks).toStrictEqual({
      json: `${CONFIG.url}${ROUTES.RSS}.json`,
      atom: `${CONFIG.url}${ROUTES.RSS}/atom`,
    });
    expect(feed.options.generator).toBe('Feed & NextJS');
    expect(feed.options.language).toBe(CONFIG.locales.defaultLocale);
    expect(feed.options.link).toBe(CONFIG.url);
    expect(feed.options.title).toBe(`${CONFIG.name} | ${CONFIG.baseline}`);
    expect(feed.items.length).toBeGreaterThan(0);
  });
  /* eslint-enable max-statements */
});