From c139b1faef8793bbf33d84ab93c448eeab8aa65b Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 30 Jan 2022 02:24:56 +0100 Subject: [PATCH] schedule support is tested --- test/example-onlyics.test.js | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 test/example-onlyics.test.js diff --git a/test/example-onlyics.test.js b/test/example-onlyics.test.js new file mode 100644 index 0000000..83a4cbc --- /dev/null +++ b/test/example-onlyics.test.js @@ -0,0 +1,60 @@ +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) + }) + }) +}) + +