example-full-spore.test.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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-spore";
  7. const expect = chai.expect;
  8. const url =
  9. "https://radiomanifest.degenerazione.xyz/v0.2/examples/" + exampleName + "/";
  10. const testShowName = "scaricomerci";
  11. const testNextShowName = "nastrone notte";
  12. describe("examples/" + exampleName, () => {
  13. describe("schedule.getNow", () => {
  14. it("observes priority correctly", async () => {
  15. // tuesday, half past midnight
  16. const rm = await radiomanifest.get(url);
  17. const rs = rm.getSchedule();
  18. const now = new ICAL.Time(
  19. {
  20. year: 2022,
  21. month: 1,
  22. day: 30,
  23. hour: 2,
  24. minute: 20,
  25. second: 0,
  26. isDate: false,
  27. },
  28. ICAL.Timezone.utcTimezone,
  29. );
  30. const vevent = rs.getNowEvent(now);
  31. assert.notEqual(vevent, null);
  32. const show = rs.getNowShow(now);
  33. assert.notEqual(show, null);
  34. assert.equal(show.getName(), testShowName);
  35. });
  36. });
  37. describe("schedule.getNext", () => {
  38. it("getNext observes priority correctly", async () => {
  39. // tuesday, half past midnight
  40. const rm = await radiomanifest.get(url);
  41. const rs = rm.getSchedule();
  42. const now = new ICAL.Time({
  43. year: 2022,
  44. month: 2,
  45. day: 2,
  46. hour: 2,
  47. minute: 20,
  48. second: 0,
  49. isDate: false,
  50. });
  51. const vevent = rs.getNowEvent(now);
  52. assert.notEqual(vevent, null);
  53. const show = rs.getNowShow(now);
  54. assert.notEqual(show, null);
  55. assert.equal(show.getName(), testShowName);
  56. const next_event = rs.getNextEvent(now);
  57. assert.notEqual(next_event, null);
  58. assert.isObject(next_event.event);
  59. assert.isObject(next_event.time);
  60. const next_show = rs.getNextShow(now);
  61. assert.isObject(next_show);
  62. assert.isObject(next_show.show);
  63. assert.equal(next_show.show.getName(), testNextShowName);
  64. const time = next_event.time.toJSDate();
  65. assert.equal(time.getHours(), 2);
  66. assert.equal(time.getMinutes(), 58);
  67. });
  68. });
  69. });