Files
epg/sites/pbsguam.org/pbsguam.org.test.js
2025-07-27 18:43:59 +02:00

45 lines
1.2 KiB
JavaScript

const { parser, url } = require('./pbsguam.org.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('2021-11-25', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '#',
xmltv_id: 'KGTF.us'
}
it('can generate valid url', () => {
expect(url).toBe('https://pbsguam.org/calendar/')
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
const result = parser({ date, content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2021-11-25T08:30:00.000Z',
stop: '2021-11-25T09:00:00.000Z',
title: 'Xavier Riddle and the Secret Museum'
}
])
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
})
expect(result).toMatchObject([])
})