mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update unifi.com.my.test.js
This commit is contained in:
parent
81581d242e
commit
a4ef81f20e
1 changed files with 22 additions and 17 deletions
|
@ -1,16 +1,18 @@
|
||||||
// npx epg-grabber --config=sites/unifi.com.my/unifi.com.my.config.js --channels=sites/unifi.com.my/unifi.com.my.channels.xml --output=guide.xml --days=2 --timeout=30000
|
// npx epg-grabber --config=sites/unifi.com.my/unifi.com.my.config.js --channels=sites/unifi.com.my/unifi.com.my.channels.xml --output=guide.xml --days=2 --timeout=30000
|
||||||
|
|
||||||
const { parser, url, request } = require('./unifi.com.my.config.js')
|
const { parser, url, request } = require('./unifi.com.my.config.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
const date = dayjs.utc('2023-01-09', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2023-01-13', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: '51882833',
|
site_id: '20000009',
|
||||||
xmltv_id: 'AXNMalaysia.my'
|
xmltv_id: 'TV1.my'
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
|
@ -23,30 +25,33 @@ it('can generate valid request method', () => {
|
||||||
|
|
||||||
it('can generate valid request headers', () => {
|
it('can generate valid request headers', () => {
|
||||||
expect(request.headers).toMatchObject({
|
expect(request.headers).toMatchObject({
|
||||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
'x-requested-with': 'XMLHttpRequest'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('can generate valid request data', () => {
|
||||||
|
const data = request.data({ date })
|
||||||
|
|
||||||
|
expect(data.get('date')).toBe('2023-01-13')
|
||||||
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
const content = `[{"id":"51882833","name":"AXN","logo":"https://playtv.unifi.com.my:7047/CPS/images/universal/film/logo/202109/20210927/2021092701574706798y.png","items":[{"name":"Blue Bloods (Season 11)","interval":"one","minute":55,"start_time":"4:20am","end_time":"5:15am"}]}]`
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||||
|
const results = parser({ content, date, channel }).map(p => {
|
||||||
const result = parser({ content, channel, date }).map(p => {
|
|
||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(result).toMatchObject([
|
expect(results[0]).toMatchObject({
|
||||||
{
|
title: 'Berita Tengah Malam',
|
||||||
title: 'Blue Bloods (Season 11)',
|
start: '2023-01-12T16:00:00.000Z',
|
||||||
start: '2023-01-08T20:20:00.000Z',
|
stop: '2023-01-12T16:30:00.000Z'
|
||||||
stop: '2023-01-08T21:15:00.000Z'
|
})
|
||||||
}
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', () => {
|
||||||
const content = `[{"id":"51882833","name":"AXN","logo":"https://playtv.unifi.com.my:7047/CPS/images/universal/film/logo/202109/20210927/2021092701574706798y.png","items":[]}]`
|
const results = parser({ content: '', channel })
|
||||||
const result = parser({ content, channel })
|
|
||||||
expect(result).toMatchObject([])
|
expect(results).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue