mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Create andorradifusio.ad.test.js
This commit is contained in:
parent
f10f72e72a
commit
2be4443eb5
1 changed files with 54 additions and 0 deletions
54
sites/andorradifusio.ad/andorradifusio.ad.test.js
Normal file
54
sites/andorradifusio.ad/andorradifusio.ad.test.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
// npx epg-grabber --config=sites/andorradifusio.ad/andorradifusio.ad.config.js --channels=sites/andorradifusio.ad/andorradifusio.ad_ad.channels.xml --output=.gh-pages/guides/ad/andorradifusio.ad.epg.xml --days=2
|
||||||
|
|
||||||
|
const { parser, url } = require('./andorradifusio.ad.config.js')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
const date = dayjs.utc('2021-11-24', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = {
|
||||||
|
site_id: 'atv',
|
||||||
|
xmltv_id: 'AndorraTV.ad'
|
||||||
|
}
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel })).toBe('https://www.andorradifusio.ad/programacio/atv')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = `<!DOCTYPE html><html lang="ca"> <head></head> <body id="rtvabody"> <div class="container"> <div class="row"> <div class="col-sm-12"> <div class="programacio-dia"> <h3>dimecres <span class="dia">24 nov.</span></h3> <h4>07:00</h4> <p>Club Piolet</p><h4>23:30</h4> <p>Informatiu vespre</p><h4>01:00</h4> <p>Àrea Andorra Difusió</p></div><div class="programacio-dia"> <h3>dijous <span class="dia">25 nov.</span></h3> <h4>07:00</h4> <p>Club Piolet</p></div></div></div></div></body></html>`
|
||||||
|
const result = parser({ content, date }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(result).toMatchObject([
|
||||||
|
{
|
||||||
|
start: '2021-11-24T06:00:00.000Z',
|
||||||
|
stop: '2021-11-24T22:30:00.000Z',
|
||||||
|
title: `Club Piolet`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
start: '2021-11-24T22:30:00.000Z',
|
||||||
|
stop: '2021-11-25T00:00:00.000Z',
|
||||||
|
title: `Informatiu vespre`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
start: '2021-11-25T00:00:00.000Z',
|
||||||
|
stop: '2021-11-25T01:00:00.000Z',
|
||||||
|
title: `Àrea Andorra Difusió`
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const result = parser({
|
||||||
|
date,
|
||||||
|
channel,
|
||||||
|
content: `<!DOCTYPE html><html><head></head><body></body></html>`
|
||||||
|
})
|
||||||
|
expect(result).toMatchObject([])
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue