mirror of
https://github.com/iptv-org/epg
synced 2026-05-07 01:46:59 -04:00
Update foxtel.com.au.test.js
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
const axios = require('axios')
|
||||||
const { parser, url, request } = require('./foxtel.com.au.config.js')
|
const { parser, url, request } = require('./foxtel.com.au.config.js')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
@@ -7,6 +8,23 @@ 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://www.foxtel.com.au/webepg/ws/foxtel/event/174868153?movieHeight=213&tvShowHeight=213®ionId=8336'
|
||||||
|
) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/program_1.json')))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: '{}'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const date = dayjs.utc('2022-11-08', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2022-11-08', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: 'Channel-9-Sydney/NIN',
|
site_id: 'Channel-9-Sydney/NIN',
|
||||||
@@ -26,10 +44,10 @@ it('can generate valid request headers', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
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'))
|
||||||
|
|
||||||
let results = parser({ content })
|
let results = await parser({ content })
|
||||||
results = results.map(p => {
|
results = results.map(p => {
|
||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
@@ -41,6 +59,8 @@ it('can parse response', () => {
|
|||||||
stop: '2022-11-07T13:30:00.000Z',
|
stop: '2022-11-07T13:30:00.000Z',
|
||||||
title: 'The Equalizer',
|
title: 'The Equalizer',
|
||||||
sub_title: 'Glory',
|
sub_title: 'Glory',
|
||||||
|
description:
|
||||||
|
"While Danny chaperones Grace's winter formal, terrorists seize the venue and hold everyone hostage in order to kidnap a diplomat's son.",
|
||||||
image:
|
image:
|
||||||
'https://images1.resources.foxtel.com.au/store2/mount1/16/3/69e0v.jpg?maxheight=90&limit=91aa1c7a2c485aeeba0706941f79f111adb35830',
|
'https://images1.resources.foxtel.com.au/store2/mount1/16/3/69e0v.jpg?maxheight=90&limit=91aa1c7a2c485aeeba0706941f79f111adb35830',
|
||||||
rating: {
|
rating: {
|
||||||
@@ -52,8 +72,8 @@ it('can parse response', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', async () => {
|
||||||
const result = parser({
|
const result = await parser({
|
||||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no-content.html'))
|
content: fs.readFileSync(path.resolve(__dirname, '__data__/no-content.html'))
|
||||||
})
|
})
|
||||||
expect(result).toMatchObject([])
|
expect(result).toMatchObject([])
|
||||||
|
|||||||
Reference in New Issue
Block a user