radiomanifest.js/test/example-full-ondarossa.test.js

105 lines
3.1 KiB
JavaScript
Raw Normal View History

2023-09-14 01:07:07 +02:00
const ICAL = require("ical.js");
2022-01-30 02:32:37 +01:00
2023-09-14 01:07:07 +02:00
const radiomanifest = require("../radiomanifest.js");
const chai = require("chai");
chai.use(require("chai-as-promised"));
const assert = chai.assert;
2022-01-30 00:26:07 +01:00
2023-09-14 01:07:07 +02:00
const exampleName = "full-ondarossa";
const expect = chai.expect;
const url =
"https://radiomanifest.degenerazione.xyz/v0.2/examples/" + exampleName + "/";
2022-01-30 00:26:07 +01:00
2023-09-14 01:07:07 +02:00
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";
2022-01-30 02:38:37 +01:00
2023-09-14 01:07:07 +02:00
describe("examples/" + exampleName, () => {
describe("shows", () => {
it("shoud find many shows", async () => {
const rm = await radiomanifest.get(url);
assert.isAbove(rm.getShows().length, 1);
});
2022-01-30 00:26:07 +01:00
it('one of which is called "Entropia Massima"', async () => {
2023-09-14 01:07:07 +02:00
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);
});
});
2022-01-30 02:32:37 +01:00
2023-09-14 01:07:07 +02:00
describe("schedule", () => {
it("should find many event", async () => {
const rm = await radiomanifest.get(url);
assert.isAbove(rm.getSchedule().getEvents().length, 1);
});
2022-01-30 02:32:37 +01:00
2023-09-14 01:07:07 +02:00
it("At 1AM, nothing is going on", async () => {
const rm = await radiomanifest.get(url);
const rs = rm.getSchedule();
2022-01-30 02:32:37 +01:00
const now = new ICAL.Time({
2023-09-14 01:07:07 +02:00
year: 2022,
month: 1,
day: 31,
hour: 1,
minute: 0,
second: 0,
isDate: false,
});
const ev = rs.getNowEvent(now);
assert.equal(ev, null);
});
2022-01-30 02:32:37 +01:00
2022-01-30 02:38:37 +01:00
it('monday at 8PM, "Entropia Massima" is going on', async () => {
2023-09-14 01:07:07 +02:00
const rm = await radiomanifest.get(url);
const rs = rm.getSchedule();
2022-01-30 02:32:37 +01:00
const now = new ICAL.Time({
2023-09-14 01:07:07 +02:00
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);
2022-01-30 02:38:37 +01:00
2023-09-14 01:07:07 +02:00
assert.equal(show.getFeed(), testFeed);
});
2022-01-30 02:38:37 +01:00
2022-02-02 10:16:12 +01:00
it('monday at 7PM, "Entropia Massima" is next', async () => {
2023-09-14 01:07:07 +02:00
const rm = await radiomanifest.get(url);
const rs = rm.getSchedule();
2022-02-02 10:16:12 +01:00
const now = new ICAL.Time({
2023-09-14 01:07:07 +02:00
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");
2022-01-30 00:26:07 +01:00
2023-09-14 01:07:07 +02:00
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);
});
});
});