mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 01:20:08 -04:00
Create tvmustra.hu.test.js
This commit is contained in:
parent
76df1541d8
commit
a650a4a23c
1 changed files with 47 additions and 0 deletions
47
sites/tvmustra.hu/tvmustra.hu.test.js
Normal file
47
sites/tvmustra.hu/tvmustra.hu.test.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
const { parser, url } = require('./tvmustra.hu.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('2025-01-17', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = {
|
||||||
|
site_id: 'M1HD',
|
||||||
|
xmltv_id: 'M1HD.hu'
|
||||||
|
}
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel, date })).toBe('https://www.tvmustra.hu/tvmusor/M1HD/2025-01-17')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||||
|
const results = parser({ content, date }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(results.length).toBe(98)
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
start: '2025-01-17T05:00:00.000Z',
|
||||||
|
stop: '2025-01-17T05:30:00.000Z',
|
||||||
|
title: 'HÍRADÓ'
|
||||||
|
})
|
||||||
|
expect(results[97]).toMatchObject({
|
||||||
|
start: '2025-01-18T04:00:00.000Z',
|
||||||
|
stop: '2025-01-18T04:30:00.000Z',
|
||||||
|
title: 'Ma éjszaka'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const results = parser({
|
||||||
|
date,
|
||||||
|
content: ''
|
||||||
|
})
|
||||||
|
expect(results).toMatchObject([])
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue