forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-rss-feeds.js
46 lines (42 loc) · 1.71 KB
/
get-rss-feeds.js
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
36
37
38
39
40
41
42
43
44
45
46
const Parser = require('rss-parser')
const { getChangelogItems } = require('../../lib/changelog')
const fs = require('fs')
const path = require('path')
const parser = new Parser({ timeout: 5000 })
const rssFeedContent = fs.readFileSync(path.join(process.cwd(), 'tests/fixtures/rss-feed.xml'), 'utf8')
describe('getChangelogItems module', () => {
let changelog
beforeAll(async () => {
const feed = await parser.parseString(rssFeedContent)
changelog = await getChangelogItems('GitHub Actions:', feed)
})
it('changelog contains 3 items', async () => {
expect(changelog.length).toEqual(3)
})
it('each changelog item has expected title, date, and href', async () => {
const expectedChangelogValues = [
{
title: 'Authentication token format updates are generally available',
date: '2021-03-31T22:22:03.000Z',
href: 'https://github.blog/changelog/2021-03-31-authentication-token-format-updates-are-generally-available'
},
{
title: 'Compare REST API now supports pagination',
date: '2021-03-23T02:49:54.000Z',
href: 'https://github.blog/changelog/2021-03-22-compare-rest-api-now-supports-pagination'
},
{
title: 'GitHub Discussions GraphQL API public beta',
date: '2021-02-23T18:21:40.000Z',
href: 'https://github.blog/changelog/2021-02-23-github-discussions-graphql-api-public-beta'
}
]
for (let i = 0; i < 3; i++) {
const changeLogEntry = changelog[i]
const expectedEntry = expectedChangelogValues[i]
expect(changeLogEntry.title).toBe(expectedEntry.title)
expect(changeLogEntry.date).toBe(expectedEntry.date)
expect(changeLogEntry.href).toBe(expectedEntry.href)
}
})
})