forked from boyska/radiomanifest.js
more tests and demos for schedule
This commit is contained in:
parent
a19dbc8de1
commit
8cde139866
3 changed files with 30 additions and 21 deletions
|
@ -46,7 +46,9 @@ class Radio {
|
|||
return this.schedule
|
||||
}
|
||||
|
||||
getShowAtTime () {
|
||||
getShowAtTime (now) {
|
||||
if (this.schedule === undefined || this.schedule === null) return null
|
||||
return this.getSchedule().getNowShow(now)
|
||||
}
|
||||
|
||||
static fromDOM (xml) {
|
||||
|
|
|
@ -9,6 +9,10 @@ const exampleName = 'full-ondarossa'
|
|||
const expect = chai.expect
|
||||
const url = 'https://radiomanifest.degenerazione.xyz/v0.2/examples/' + exampleName + '/'
|
||||
|
||||
const testShowName = 'Entropia Massima'
|
||||
const testWebsite = "http://www.ondarossa.info/trx/entropia-massima"
|
||||
const testFeed = 'http://www.ondarossa.info/podcast/by-trx-id/10497/podcast.xml'
|
||||
|
||||
describe('examples/' + exampleName, () => {
|
||||
describe('shows', () => {
|
||||
it('shoud find many shows', async () => {
|
||||
|
@ -17,9 +21,9 @@ describe('examples/' + exampleName, () => {
|
|||
})
|
||||
it('one of which is called "Entropia Massima"', async () => {
|
||||
const rm = await radiomanifest.get(url)
|
||||
const show = rm.getShowByName("Entropia Massima")
|
||||
assert.equal(show.getName(), "Entropia Massima")
|
||||
assert.equal(show.getWebsite(), "http://www.ondarossa.info/trx/entropia-massima")
|
||||
const show = rm.getShowByName(testShowName)
|
||||
assert.equal(show.getName(), testShowName)
|
||||
assert.equal(show.getWebsite(), testWebsite)
|
||||
assert.equal(show.getSchedule(), null)
|
||||
})
|
||||
})
|
||||
|
@ -30,6 +34,22 @@ describe('examples/' + exampleName, () => {
|
|||
assert.isAbove(rm.getSchedule().getEvents().length, 1)
|
||||
})
|
||||
|
||||
it('At 1AM, nothing is going on', async () => {
|
||||
const rm = await radiomanifest.get(url)
|
||||
const rs = rm.getSchedule()
|
||||
const now = new ICAL.Time({
|
||||
year: 2022,
|
||||
month: 1,
|
||||
day: 31,
|
||||
hour: 1,
|
||||
minute: 0,
|
||||
second: 0,
|
||||
isDate: false
|
||||
});
|
||||
const ev = rs.getNowEvent(now)
|
||||
assert.equal(ev, null)
|
||||
})
|
||||
|
||||
it('monday at 8PM, "Entropia Massima" is going on', async () => {
|
||||
const rm = await radiomanifest.get(url)
|
||||
const rs = rm.getSchedule()
|
||||
|
@ -47,24 +67,11 @@ describe('examples/' + exampleName, () => {
|
|||
assert.notEqual(vevent, null)
|
||||
const show = rs.getNowShow(now)
|
||||
assert.notEqual(show, null)
|
||||
assert.equal(show.getName(), 'Entropia Massima')
|
||||
assert.equal(show.getName(), testShowName)
|
||||
|
||||
assert.equal(show.getFeed(), testFeed)
|
||||
})
|
||||
|
||||
it('At 1AM, nothing is going on', async () => {
|
||||
const rm = await radiomanifest.get(url)
|
||||
const rs = rm.getSchedule()
|
||||
const now = new ICAL.Time({
|
||||
year: 2022,
|
||||
month: 1,
|
||||
day: 31,
|
||||
hour: 1,
|
||||
minute: 0,
|
||||
second: 0,
|
||||
isDate: false
|
||||
});
|
||||
const ev = rs.getNowEvent(now)
|
||||
assert.equal(ev, null)
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
|
2
ui.js
2
ui.js
|
@ -4,7 +4,7 @@ function updateNow(radio) {
|
|||
var box = document.querySelector('#now-info')
|
||||
const show = radio.getSchedule().getNowShow()
|
||||
try {
|
||||
var text = show.getName()
|
||||
var text = show.getName() + '\nfeed: ' + show.getWebsite()
|
||||
} catch (e) {
|
||||
var text = String(show)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue