const { parser, url } = require('./znbc.co.zm.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-25', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: 'tv1',
xmltv_id: 'ZNBCTV1.zm'
}
const content =
'
'
it('can generate valid url', () => {
expect(url({ channel })).toBe('https://www.znbc.co.zm/tv1/')
})
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-24T22:00:00.000Z',
stop: '2021-11-24T23:00:00.000Z',
title: 'MAIN NEWS – RPT'
},
{
start: '2021-11-24T23:00:00.000Z',
stop: '2021-11-25T00:00:00.000Z',
title: 'BORN & BRED – Rebroadcast (Tuesday Edition)'
},
{
start: '2021-11-25T00:00:00.000Z',
stop: '2021-11-25T00:30:00.000Z',
title: 'DOCUMENTARY – DW'
}
])
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: ''
})
expect(result).toMatchObject([])
})