mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 17:10:07 -04:00
Update andorradifusio.ad.test.js
This commit is contained in:
parent
7682981d7e
commit
54d2b1d869
1 changed files with 17 additions and 22 deletions
|
@ -1,13 +1,15 @@
|
||||||
// npx epg-grabber --config=sites/andorradifusio.ad/andorradifusio.ad.config.js --channels=sites/andorradifusio.ad/andorradifusio.ad.channels.xml --output=guide.xml --days=2
|
// npx epg-grabber --config=sites/andorradifusio.ad/andorradifusio.ad.config.js --channels=sites/andorradifusio.ad/andorradifusio.ad.channels.xml --output=guide.xml
|
||||||
|
|
||||||
const { parser, url } = require('./andorradifusio.ad.config.js')
|
const { parser, url } = require('./andorradifusio.ad.config.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
const date = dayjs.utc('2021-11-24', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2023-06-07', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: 'atv',
|
site_id: 'atv',
|
||||||
xmltv_id: 'AndorraTV.ad'
|
xmltv_id: 'AndorraTV.ad'
|
||||||
|
@ -18,36 +20,29 @@ it('can generate valid url', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
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 content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||||
const result = parser({ content, date }).map(p => {
|
const results = parser({ content, date }).map(p => {
|
||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(result).toMatchObject([
|
expect(results[0]).toMatchObject({
|
||||||
{
|
start: '2023-06-07T05:00:00.000Z',
|
||||||
start: '2021-11-24T06:00:00.000Z',
|
stop: '2023-06-07T06:00:00.000Z',
|
||||||
stop: '2021-11-24T22:30:00.000Z',
|
|
||||||
title: `Club Piolet`
|
title: `Club Piolet`
|
||||||
},
|
})
|
||||||
{
|
|
||||||
start: '2021-11-24T22:30:00.000Z',
|
expect(results[20]).toMatchObject({
|
||||||
stop: '2021-11-25T00:00:00.000Z',
|
start: '2023-06-07T23:00:00.000Z',
|
||||||
title: `Informatiu vespre`
|
stop: '2023-06-08T00:00:00.000Z',
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2021-11-25T00:00:00.000Z',
|
|
||||||
stop: '2021-11-25T01:00:00.000Z',
|
|
||||||
title: `Àrea Andorra Difusió`
|
title: `Àrea Andorra Difusió`
|
||||||
}
|
})
|
||||||
])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', () => {
|
||||||
const result = parser({
|
const result = parser({
|
||||||
date,
|
date,
|
||||||
channel,
|
|
||||||
content: `<!DOCTYPE html><html><head></head><body></body></html>`
|
content: `<!DOCTYPE html><html><head></head><body></body></html>`
|
||||||
})
|
})
|
||||||
expect(result).toMatchObject([])
|
expect(result).toMatchObject([])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue