forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cableplus.com.uy.test.js
73 lines (62 loc) · 2.14 KB
/
cableplus.com.uy.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
61
62
63
64
65
66
67
68
69
70
71
72
73
const { parser, url, request } = require('./cableplus.com.uy.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('2023-02-12', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '2035',
xmltv_id: 'APlusV.uy'
}
it('can generate valid url', () => {
expect(url).toBe('https://www.reportv.com.ar/finder/channel')
})
it('can generate valid request method', () => {
expect(request.method).toBe('POST')
})
it('can generate valid request headers', () => {
expect(request.headers).toMatchObject({
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
})
})
it('can generate valid request data', () => {
const params = request.data({ date, channel })
expect(params.get('idAlineacion')).toBe('3017')
expect(params.get('idSenial')).toBe('2035')
expect(params.get('fecha')).toBe('2023-02-12')
expect(params.get('hora')).toBe('00:00')
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
let results = parser({ content, date })
results = results.map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(21)
expect(results[0]).toMatchObject({
start: '2023-02-12T09:30:00.000Z',
stop: '2023-02-12T10:30:00.000Z',
title: 'Revista agropecuaria',
icon: 'https://www.reportv.com.ar/buscador/img/Programas/2797844.jpg',
categories: []
})
expect(results[4]).toMatchObject({
start: '2023-02-12T12:30:00.000Z',
stop: '2023-02-12T13:30:00.000Z',
title: 'De pago en pago',
icon: 'https://www.reportv.com.ar/buscador/img/Programas/3772835.jpg',
categories: ['Cultural']
})
})
it('can handle empty guide', () => {
const result = parser({
date,
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
})
expect(result).toMatchObject([])
})