123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- 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-spore";
- const expect = chai.expect;
- const url =
- "https://radiomanifest.degenerazione.xyz/v0.2/examples/" + exampleName + "/";
- const testShowName = "scaricomerci";
- const testNextShowName = "nastrone notte";
- describe("examples/" + exampleName, () => {
- describe("schedule.getNow", () => {
- it("observes priority correctly", async () => {
- // tuesday, half past midnight
- const rm = await radiomanifest.get(url);
- const rs = rm.getSchedule();
- const now = new ICAL.Time(
- {
- year: 2022,
- month: 1,
- day: 30,
- hour: 2,
- minute: 20,
- second: 0,
- isDate: false,
- },
- ICAL.Timezone.utcTimezone,
- );
- const vevent = rs.getNowEvent(now);
- assert.notEqual(vevent, null);
- const show = rs.getNowShow(now);
- assert.notEqual(show, null);
- assert.equal(show.getName(), testShowName);
- });
- });
- describe("schedule.getNext", () => {
- it("getNext observes priority correctly", async () => {
- // tuesday, half past midnight
- const rm = await radiomanifest.get(url);
- const rs = rm.getSchedule();
- const now = new ICAL.Time({
- year: 2022,
- month: 2,
- day: 2,
- hour: 2,
- minute: 20,
- 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);
- const next_event = rs.getNextEvent(now);
- assert.notEqual(next_event, null);
- assert.isObject(next_event.event);
- assert.isObject(next_event.time);
- const next_show = rs.getNextShow(now);
- assert.isObject(next_show);
- assert.isObject(next_show.show);
- assert.equal(next_show.show.getName(), testNextShowName);
- const time = next_event.time.toJSDate();
- assert.equal(time.getHours(), 2);
- assert.equal(time.getMinutes(), 58);
- });
- });
- });
|