epg/sites/nzxmltv.com/nzxmltv.com.test.js
Toha 25a4fe8877
Add nzxmltv.com.
Signed-off-by: Toha <tohenk@yahoo.com>
2023-11-23 22:41:03 +07:00

43 lines
1.3 KiB
JavaScript

// npm run channels:parse -- --config=./sites/nzxmltv.com/nzxmltv.com.config.js --output=./sites/nzxmltv.com/nzxmltv.com.channels.xml
// npm run grab -- --site=nzxmltv.com
const { parser, url } = require('./nzxmltv.com.config.js')
const fs = require('fs')
const path = require('path')
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('2023-11-21').startOf('d')
const channel = {
site_id: '1',
xmltv_id: 'TVNZ1.nz'
}
it('can generate valid url', () => {
expect(url).toBe('https://nzxmltv.com/xmltv/guide.xml')
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml'))
const results = parser({ content, channel, date })
expect(results[0]).toMatchObject({
start: '2023-11-21T10:30:00.000Z',
stop: '2023-11-21T11:25:00.000Z',
title: 'Sunday',
description:
'On Sunday, an unmissable show with stories about divorce, weight loss, and the incomprehensible devastation of Gaza.',
season: 2023,
episode: 37,
icon: 'https://www.thetvdb.com/banners/posters/5dbebff2986f2.jpg'
})
})
it('can handle empty guide', () => {
const result = parser({ content: '', channel, date })
expect(result).toMatchObject([])
})