mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update tvtv.us.test.js
This commit is contained in:
parent
378d138694
commit
cffd2a635f
1 changed files with 128 additions and 5 deletions
|
@ -1,12 +1,25 @@
|
||||||
const { parser, url } = require('./tvtv.us.config.js')
|
const { parser, url } = require('./tvtv.us.config.js')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const axios = require('axios')
|
||||||
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)
|
||||||
|
|
||||||
|
jest.mock('axios')
|
||||||
|
|
||||||
|
axios.get.mockImplementation(url => {
|
||||||
|
if (url === 'https://tvtv.us/api/v1/programs/EP009311820269') {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/program_1.json')))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return Promise.resolve({ data: '' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const date = dayjs.utc('2025-01-30', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2025-01-30', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = { site_id: '20373' }
|
const channel = { site_id: '20373' }
|
||||||
|
|
||||||
|
@ -16,10 +29,11 @@ it('can generate valid url', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', async () => {
|
||||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||||
|
|
||||||
const results = parser({ content }).map(p => {
|
let results = await parser({ content })
|
||||||
|
results = results.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
|
||||||
|
@ -36,13 +50,122 @@ it('can parse response', () => {
|
||||||
start: '2025-01-30T00:30:00.000Z',
|
start: '2025-01-30T00:30:00.000Z',
|
||||||
stop: '2025-01-30T01:00:00.000Z',
|
stop: '2025-01-30T01:00:00.000Z',
|
||||||
title: 'The Big Bang Theory',
|
title: 'The Big Bang Theory',
|
||||||
subtitle: 'The Bow Tie Asymmetry'
|
subtitle: 'The Bow Tie Asymmetry',
|
||||||
|
description:
|
||||||
|
"When Amy's parents and Sheldon's family arrive, everybody is focused on making sure the wedding arrangements go according to plan -- everyone except the bride and groom.",
|
||||||
|
image: 'https://tvtv.us/gn/pi/assets/p185554_b_v11_az.jpg?w=240&h=360',
|
||||||
|
date: '2018',
|
||||||
|
season: 11,
|
||||||
|
episode: 24,
|
||||||
|
actors: [
|
||||||
|
{
|
||||||
|
value: 'Johnny Galecki',
|
||||||
|
role: 'Leonard Hofstadter'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Jim Parsons',
|
||||||
|
role: 'Sheldon Cooper'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Kaley Cuoco',
|
||||||
|
role: 'Penny'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Simon Helberg',
|
||||||
|
role: 'Howard Wolowitz'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Kunal Nayyar',
|
||||||
|
role: 'Raj Koothrappali'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Mayim Bialik',
|
||||||
|
role: 'Amy Farrah Fowler'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Melissa Rauch',
|
||||||
|
role: 'Bernadette Rostenkowski'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Kevin Sussman',
|
||||||
|
role: 'Stuart',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Laurie Metcalf',
|
||||||
|
role: 'Mary',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'John Ross Bowie',
|
||||||
|
role: 'Kripke',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Wil Wheaton',
|
||||||
|
role: 'Himself',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Brian Posehn',
|
||||||
|
role: 'Bert',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "Jerry O'Connell",
|
||||||
|
role: 'George',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Courtney Henggeler',
|
||||||
|
role: 'Missy',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Lauren Lapkus',
|
||||||
|
role: 'Denise',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Teller',
|
||||||
|
role: 'Mr. Fowler',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Kathy Bates',
|
||||||
|
role: 'Mrs. Fowler',
|
||||||
|
guest: 'yes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'Mark Hamill',
|
||||||
|
role: 'Himself',
|
||||||
|
guest: 'yes'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
directors: ['Mark Cendrowski'],
|
||||||
|
producers: ['Chuck Lorre', 'Bill Prady', 'Steven Molaro'],
|
||||||
|
writers: [
|
||||||
|
'Chuck Lorre',
|
||||||
|
'Steven Molaro',
|
||||||
|
'Maria Ferrari',
|
||||||
|
'Steve Holland',
|
||||||
|
'Eric Kaplan',
|
||||||
|
'Tara Hernandez'
|
||||||
|
],
|
||||||
|
categories: ['Sitcom'],
|
||||||
|
ratings: [
|
||||||
|
{
|
||||||
|
value: 'TVPG',
|
||||||
|
system: 'USA Parental Rating'
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', async () => {
|
||||||
const results = parser({
|
const results = await parser({
|
||||||
content: '[]'
|
content: '[]'
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(results).toMatchObject([])
|
expect(results).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue