example-full-ondarossa.test.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. const ICAL = require('ical.js')
  2. const radiomanifest = require('../radiomanifest.js')
  3. const chai = require('chai')
  4. chai.use(require('chai-as-promised'))
  5. const assert = chai.assert
  6. const exampleName = 'full-ondarossa'
  7. const expect = chai.expect
  8. const url = 'https://radiomanifest.degenerazione.xyz/v0.2/examples/' + exampleName + '/'
  9. const testShowName = 'Entropia Massima'
  10. const testWebsite = "http://www.ondarossa.info/trx/entropia-massima"
  11. const testFeed = 'http://www.ondarossa.info/podcast/by-trx-id/10497/podcast.xml'
  12. describe('examples/' + exampleName, () => {
  13. describe('shows', () => {
  14. it('shoud find many shows', async () => {
  15. const rm = await radiomanifest.get(url)
  16. assert.isAbove(rm.getShows().length, 1)
  17. })
  18. it('one of which is called "Entropia Massima"', async () => {
  19. const rm = await radiomanifest.get(url)
  20. const show = rm.getShowByName(testShowName)
  21. assert.equal(show.getName(), testShowName)
  22. assert.equal(show.getWebsite(), testWebsite)
  23. assert.equal(show.getSchedule(), null)
  24. })
  25. })
  26. describe('schedule', () => {
  27. it('should find many event', async () => {
  28. const rm = await radiomanifest.get(url)
  29. assert.isAbove(rm.getSchedule().getEvents().length, 1)
  30. })
  31. it('At 1AM, nothing is going on', async () => {
  32. const rm = await radiomanifest.get(url)
  33. const rs = rm.getSchedule()
  34. const now = new ICAL.Time({
  35. year: 2022,
  36. month: 1,
  37. day: 31,
  38. hour: 1,
  39. minute: 0,
  40. second: 0,
  41. isDate: false
  42. });
  43. const ev = rs.getNowEvent(now)
  44. assert.equal(ev, null)
  45. })
  46. it('monday at 8PM, "Entropia Massima" is going on', async () => {
  47. const rm = await radiomanifest.get(url)
  48. const rs = rm.getSchedule()
  49. const now = new ICAL.Time({
  50. year: 2022,
  51. month: 1,
  52. day: 31,
  53. hour: 20,
  54. minute: 10,
  55. second: 0,
  56. isDate: false
  57. },
  58. );
  59. const vevent = rs.getNowEvent(now)
  60. assert.notEqual(vevent, null)
  61. const show = rs.getNowShow(now)
  62. assert.notEqual(show, null)
  63. assert.equal(show.getName(), testShowName)
  64. assert.equal(show.getFeed(), testFeed)
  65. })
  66. it('monday at 7PM, "Entropia Massima" is next', async () => {
  67. const rm = await radiomanifest.get(url)
  68. const rs = rm.getSchedule()
  69. const now = new ICAL.Time({
  70. year: 2022,
  71. month: 1,
  72. day: 31,
  73. hour: 19,
  74. minute: 10,
  75. second: 0,
  76. isDate: false
  77. },
  78. );
  79. const vevent = rs.getNowEvent(now)
  80. assert.notEqual(vevent, null)
  81. const show = rs.getNowShow(now)
  82. assert.notEqual(show, null)
  83. assert.equal(show.getName(), 'Baraonda')
  84. const next_event = rs.getNextEvent(now)
  85. assert.notEqual(next_event, null)
  86. assert.notEqual(next_event.event, null)
  87. const next_show = rs.getNextShow(now)
  88. assert.notEqual(next_show, null)
  89. assert.notEqual(next_show.show, null)
  90. assert.equal(next_show.show.getName(), testShowName)
  91. assert.equal(next_show.show.getFeed(), testFeed)
  92. })
  93. })
  94. })