1
0

example-onlyics.test.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 = 'onlyics'
  7. const expect = chai.expect
  8. const url = 'https://radiomanifest.degenerazione.xyz/v0.2/examples/' + exampleName + '/'
  9. describe('examples/' + exampleName, () => {
  10. describe('schedule', () => {
  11. it('should find one event', async () => {
  12. const rm = await radiomanifest.get(url)
  13. assert.equal(rm.getSchedule().getEvents().length, 1)
  14. })
  15. it('with a specific name', async () => {
  16. const rm = await radiomanifest.get(url)
  17. const ev = rm.getSchedule().getEvents()[0]
  18. const summary = ev.getFirstProperty('summary').getFirstValue()
  19. assert.equal(summary, 'JavaScript show')
  20. })
  21. it('happens every monday at 6AM', async () => {
  22. const rm = await radiomanifest.get(url)
  23. const rs = rm.getSchedule()
  24. const now = new ICAL.Time({
  25. year: 2022,
  26. month: 1,
  27. day: 3,
  28. hour: 6,
  29. minute: 30,
  30. second: 0,
  31. isDate: false
  32. });
  33. const show = rs.getNowShow(now)
  34. assert.notEqual(show, null)
  35. assert.equal(show.getName(), 'JavaScript show')
  36. })
  37. it('doesnt happen at any other time than 6AM', async () => {
  38. const rm = await radiomanifest.get(url)
  39. const rs = rm.getSchedule()
  40. const now = new ICAL.Time({
  41. year: 2022,
  42. month: 1,
  43. day: 3,
  44. hour: 9,
  45. minute: 0,
  46. second: 0,
  47. isDate: false
  48. });
  49. const ev = rs.getNowEvent(now)
  50. assert.equal(ev, null)
  51. })
  52. })
  53. })