123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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)
- })
- })
- })
|