// npx epg-grabber --config=sites/cosmote.gr/cosmote.gr.config.js --channels=sites/cosmote.gr/cosmote.gr_gr.channels.xml --output=guide.xml --days=2
const { parser, url } = require('./cosmote.gr.config.js')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(customParseFormat)
const date = dayjs.utc('2021-11-25', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '4e',
xmltv_id: '4E.gr'
}
const content = `
`
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://www.cosmote.gr/cosmotetv/residential/program/epg/programchannel?p_p_id=channelprogram_WAR_OTETVportlet&p_p_lifecycle=0&_channelprogram_WAR_OTETVportlet_platform=IPTV&_channelprogram_WAR_OTETVportlet_date=25-11-2021&_channelprogram_WAR_OTETVportlet_articleTitleUrl=4e'
)
})
it('can parse response', () => {
const result = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2021-11-24T23:15:00.000Z',
stop: '2021-11-24T23:50:00.000Z',
title: `Μαθαίνω να Είμαι Γονιός`,
category: 'Ντοκιμαντέρ'
},
{
start: '2021-11-25T21:00:00.000Z',
stop: '2021-11-25T21:45:00.000Z',
title: `Μικρό Απόδειπνο`,
category: 'Special'
},
{
start: '2021-11-25T21:45:00.000Z',
stop: '2021-11-26T01:00:00.000Z',
title: `Πανηγυρική Αρχιερατική Θεία Λειτουργία`,
category: 'Special'
}
])
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: ``
})
expect(result).toMatchObject([])
})