123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- const ICAL = require("ical.js");
- const radiomanifest = require("../radiomanifest.js");
- const chai = require("chai");
- chai.use(require("chai-as-promised"));
- const assert = chai.assert;
- const exampleName = "full-ondarossa";
- const expect = chai.expect;
- const url =
- "https://radiomanifest.degenerazione.xyz/v0.2/examples/" + exampleName + "/";
- const testShowName = "Entropia Massima";
- const testWebsite = "http://www.ondarossa.info/trx/entropia-massima";
- const testFeed =
- "http://www.ondarossa.info/podcast/by-trx-id/10497/podcast.xml";
- describe("examples/" + exampleName, () => {
- describe("shows", () => {
- it("shoud find many shows", async () => {
- const rm = await radiomanifest.get(url);
- assert.isAbove(rm.getShows().length, 1);
- });
- it('one of which is called "Entropia Massima"', async () => {
- const rm = await radiomanifest.get(url);
- const show = rm.getShowByName(testShowName);
- assert.equal(show.getName(), testShowName);
- assert.equal(show.getWebsite(), testWebsite);
- assert.equal(show.getSchedule(), null);
- });
- });
- describe("schedule", () => {
- it("should find many event", async () => {
- const rm = await radiomanifest.get(url);
- assert.isAbove(rm.getSchedule().getEvents().length, 1);
- });
- it("At 1AM, nothing is going on", async () => {
- const rm = await radiomanifest.get(url);
- const rs = rm.getSchedule();
- const now = new ICAL.Time({
- year: 2022,
- month: 1,
- day: 31,
- hour: 1,
- minute: 0,
- second: 0,
- isDate: false,
- });
- const ev = rs.getNowEvent(now);
- assert.equal(ev, null);
- });
- it('monday at 8PM, "Entropia Massima" is going on', async () => {
- const rm = await radiomanifest.get(url);
- const rs = rm.getSchedule();
- const now = new ICAL.Time({
- year: 2022,
- month: 1,
- day: 31,
- hour: 20,
- minute: 10,
- second: 0,
- isDate: false,
- });
- const vevent = rs.getNowEvent(now);
- assert.notEqual(vevent, null);
- const show = rs.getNowShow(now);
- assert.notEqual(show, null);
- assert.equal(show.getName(), testShowName);
- assert.equal(show.getFeed(), testFeed);
- });
- it('monday at 7PM, "Entropia Massima" is next', async () => {
- const rm = await radiomanifest.get(url);
- const rs = rm.getSchedule();
- const now = new ICAL.Time({
- year: 2022,
- month: 1,
- day: 31,
- hour: 19,
- minute: 10,
- second: 0,
- isDate: false,
- });
- const vevent = rs.getNowEvent(now);
- assert.notEqual(vevent, null);
- const show = rs.getNowShow(now);
- assert.notEqual(show, null);
- assert.equal(show.getName(), "Baraonda");
- const next_event = rs.getNextEvent(now);
- assert.notEqual(next_event, null);
- assert.notEqual(next_event.event, null);
- const next_show = rs.getNextShow(now);
- assert.notEqual(next_show, null);
- assert.notEqual(next_show.show, null);
- assert.equal(next_show.show.getName(), testShowName);
- assert.equal(next_show.show.getFeed(), testFeed);
- });
- });
- });
|