From 186ed67a8d0c899860c13c40d710dce68f8aff0f Mon Sep 17 00:00:00 2001 From: boyska Date: Wed, 2 Feb 2022 10:16:30 +0100 Subject: [PATCH] more tests for getNext --- test/example-full-spore.test.js | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 test/example-full-spore.test.js diff --git a/test/example-full-spore.test.js b/test/example-full-spore.test.js new file mode 100644 index 0000000..2f5c607 --- /dev/null +++ b/test/example-full-spore.test.js @@ -0,0 +1,79 @@ +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) + }) + + }) + +}) + +