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 = 'onlyics' const expect = chai.expect const url = 'https://radiomanifest.degenerazione.xyz/v0.2/examples/' + exampleName + '/' describe('examples/' + exampleName, () => { describe('schedule', () => { it('should find one event', async () => { const rm = await radiomanifest.get(url) assert.equal(rm.getSchedule().getEvents().length, 1) }) it('with a specific name', async () => { const rm = await radiomanifest.get(url) const ev = rm.getSchedule().getEvents()[0] const summary = ev.getFirstProperty('summary').getFirstValue() assert.equal(summary, 'JavaScript show') }) it('happens every monday at 6AM', async () => { const rm = await radiomanifest.get(url) const rs = rm.getSchedule() const now = new ICAL.Time({ year: 2022, month: 1, day: 3, hour: 6, minute: 30, second: 0, isDate: false }); const show = rs.getNowShow(now) assert.notEqual(show, null) assert.equal(show.getName(), 'JavaScript show') }) it('doesnt happen at any other time than 6AM', async () => { const rm = await radiomanifest.get(url) const rs = rm.getSchedule() const now = new ICAL.Time({ year: 2022, month: 1, day: 3, hour: 9, minute: 0, second: 0, isDate: false }); const ev = rs.getNowEvent(now) assert.equal(ev, null) }) }) })