From f7e6f42216c3cbeab9add475a61bb407c6be3519 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 30 Nov 2023 13:12:45 +0100 Subject: refactor(pages): refine RSS feed * add favicon * add item categories * add item image * add item author * add item update date (it seems `date` is used as update date by Feed) * change copyright format * fix ESlint errors * fix atom and json links --- src/utils/helpers/rss.test.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/utils/helpers/rss.test.ts (limited to 'src/utils/helpers/rss.test.ts') diff --git a/src/utils/helpers/rss.test.ts b/src/utils/helpers/rss.test.ts new file mode 100644 index 0000000..b04f6d3 --- /dev/null +++ b/src/utils/helpers/rss.test.ts @@ -0,0 +1,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 */ +}); -- cgit v1.2.3