forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tvpassport.com.test.js
60 lines (53 loc) · 1.81 KB
/
tvpassport.com.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const { parser, url, request } = require('./tvpassport.com.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('2022-10-04', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: 'youtoo-america-network/5463',
xmltv_id: 'YTATV.us'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://www.tvpassport.com/tv-listings/stations/youtoo-america-network/5463/2022-10-04'
)
})
it('can generate valid request headers', () => {
expect(request.headers).toMatchObject({
Cookie: 'cisession=e49ff13191d6875887193cae9e324b44ef85768d;'
})
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
let results = parser({ content })
results = results.map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results[0]).toMatchObject({
start: '2022-10-04T10:00:00.000Z',
stop: '2022-10-04T10:30:00.000Z',
title: 'Charlie Moore: No Offense',
sub_title: 'Under the Influencer',
category: ['Sports', 'Outdoors'],
icon: 'https://cdn.tvpassport.com/image/show/960x540/69103.jpg',
rating: {
system: 'MPA',
value: 'TV-G'
},
actors: ['John Reardon', 'Mayko Nguyen', 'Justin Kelly'],
director: ['Rob McElhenney'],
guest: ['Sean Penn'],
description:
'Celebrity interviews while fishing in various locations throughout the United States.'
})
})
it('can handle empty guide', () => {
const result = parser({ content: '' })
expect(result).toMatchObject([])
})