Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

get-rss-feeds.js 1.7 KB

You have to be logged in to leave a comment. Sign In
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
  1. const Parser = require('rss-parser')
  2. const { getChangelogItems } = require('../../lib/changelog')
  3. const fs = require('fs')
  4. const path = require('path')
  5. const parser = new Parser({ timeout: 5000 })
  6. const rssFeedContent = fs.readFileSync(path.join(process.cwd(), 'tests/fixtures/rss-feed.xml'), 'utf8')
  7. describe('getChangelogItems module', () => {
  8. let changelog
  9. beforeAll(async () => {
  10. const feed = await parser.parseString(rssFeedContent)
  11. changelog = await getChangelogItems('GitHub Actions:', feed)
  12. })
  13. it('changelog contains 3 items', async () => {
  14. expect(changelog.length).toEqual(3)
  15. })
  16. it('each changelog item has expected title, date, and href', async () => {
  17. const expectedChangelogValues = [
  18. {
  19. title: 'Authentication token format updates are generally available',
  20. date: '2021-03-31T22:22:03.000Z',
  21. href: 'https://github.blog/changelog/2021-03-31-authentication-token-format-updates-are-generally-available'
  22. },
  23. {
  24. title: 'Compare REST API now supports pagination',
  25. date: '2021-03-23T02:49:54.000Z',
  26. href: 'https://github.blog/changelog/2021-03-22-compare-rest-api-now-supports-pagination'
  27. },
  28. {
  29. title: 'GitHub Discussions GraphQL API public beta',
  30. date: '2021-02-23T18:21:40.000Z',
  31. href: 'https://github.blog/changelog/2021-02-23-github-discussions-graphql-api-public-beta'
  32. }
  33. ]
  34. for (let i = 0; i < 3; i++) {
  35. const changeLogEntry = changelog[i]
  36. const expectedEntry = expectedChangelogValues[i]
  37. expect(changeLogEntry.title).toBe(expectedEntry.title)
  38. expect(changeLogEntry.date).toBe(expectedEntry.date)
  39. expect(changeLogEntry.href).toBe(expectedEntry.href)
  40. }
  41. })
  42. })
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...