mirror of
https://github.com/iptv-org/epg
synced 2026-05-08 18:36:59 -04:00
Update programtv.onet.pl.test.js
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
const { parser, url } = require('./programtv.onet.pl.config.js')
|
const { parser, url } = require('./programtv.onet.pl.config.js')
|
||||||
|
const axios = require('axios')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
@@ -7,6 +8,20 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
jest.mock('axios')
|
||||||
|
|
||||||
|
axios.get.mockImplementation(url => {
|
||||||
|
if (url === 'https://programtv.onet.pl/tv/law-and-order-odcinek-15/rlmzu?entry=21970867') {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: fs.readFileSync(path.resolve(__dirname, '__data__/entry.html'))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const date = dayjs.utc('2021-11-24', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2021-11-24', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: '13th-street-250',
|
site_id: '13th-street-250',
|
||||||
@@ -35,9 +50,9 @@ it('can generate valid url for next day', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', async () => {
|
||||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||||
const result = parser({ content, date }).map(p => {
|
const result = (await parser({ content, 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
|
||||||
@@ -50,7 +65,8 @@ it('can parse response', () => {
|
|||||||
title: 'Law & Order, odc. 15: Letzte Worte',
|
title: 'Law & Order, odc. 15: Letzte Worte',
|
||||||
category: 'Krimiserie',
|
category: 'Krimiserie',
|
||||||
description:
|
description:
|
||||||
'Bei einer Reality-TV-Show stirbt einer der Teilnehmer. Zunächst tappen Briscoe (Jerry Orbach) und Green (Jesse L....'
|
'Bei einer Reality-TV-Show stirbt einer der Teilnehmer. Zunächst tappen Briscoe (Jerry Orbach) und Green (Jesse L....',
|
||||||
|
image: 'https://ocdn.eu/ptv-imported-images/akpa4046117.jpg'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
start: '2021-11-24T22:30:00.000Z',
|
start: '2021-11-24T22:30:00.000Z',
|
||||||
@@ -71,8 +87,8 @@ it('can parse response', () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', async () => {
|
||||||
const result = parser({
|
const result = await parser({
|
||||||
date,
|
date,
|
||||||
channel,
|
channel,
|
||||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||||
|
|||||||
Reference in New Issue
Block a user