mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Create epg.112114.xyz.test.js
This commit is contained in:
parent
b8de28e035
commit
2535942b5c
1 changed files with 42 additions and 0 deletions
42
sites/epg.112114.xyz/epg.112114.xyz.test.js
Normal file
42
sites/epg.112114.xyz/epg.112114.xyz.test.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
const { parser, url } = require('./epg.112114.xyz.config.js')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
|
||||||
|
const date = dayjs.utc('2025-01-11', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = { site_id: 'BTV文艺', xmltv_id: 'BRTVArtsChannel.cn', lang: 'zh' }
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url).toBe('https://epg.112114.xyz/pp.xml')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml'))
|
||||||
|
const results = parser({ date, content, channel })
|
||||||
|
|
||||||
|
expect(results.length).toBe(28)
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
start: '2025-01-11T00:07:00.000Z',
|
||||||
|
stop: '2025-01-11T00:24:00.000Z',
|
||||||
|
title: '每日文艺播报'
|
||||||
|
})
|
||||||
|
expect(results[27]).toMatchObject({
|
||||||
|
start: '2025-01-11T15:16:00.000Z',
|
||||||
|
stop: '2025-01-11T15:59:00.000Z',
|
||||||
|
title: '笑动剧场'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const result = parser({
|
||||||
|
date,
|
||||||
|
channel,
|
||||||
|
content: ''
|
||||||
|
})
|
||||||
|
expect(result).toMatchObject([])
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue