example-full-ondarossa.test.js 3.1 KB

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