-
-
Notifications
You must be signed in to change notification settings - Fork 246
/
Copy pathvisionplus.id.test.js
73 lines (63 loc) · 2.66 KB
/
visionplus.id.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 } = require('./visionplus.id.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)
jest.mock('axios')
const date = dayjs.utc('2024-11-24', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '00000000000000000079',
xmltv_id: 'AXN.id',
lang: 'en'
}
const channelId = { ...channel, lang: 'id' }
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=ENG&serviceId=00000000000000000079&start=2024-11-24T00%3A00%3A00Z&end=2024-11-25T00%3A00%3A00Z&view=cd-events-grid-view'
)
expect(url({ channel: channelId, date })).toBe(
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=IND&serviceId=00000000000000000079&start=2024-11-24T00%3A00%3A00Z&end=2024-11-25T00%3A00%3A00Z&view=cd-events-grid-view'
)
})
it('can parse response', () => {
let content = fs.readFileSync(path.resolve(__dirname, '__data__/content_en.json'))
let results = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(1)
expect(results[0]).toMatchObject({
start: '2024-11-23T23:30:00.000Z',
stop: '2024-11-24T00:15:00.000Z',
title: 'FBI: Most Wanted S4, Ep 18',
description:
'After two agents from the Bureau of Land Management go missing while executing a land seizure warrant in Wyoming, the Fugitive Task Force heads west to track them down in an unwelcoming county.',
season: 4,
episode: 18
})
content = fs.readFileSync(path.resolve(__dirname, '__data__/content_id.json'))
results = parser({ content, channel: channelId, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(1)
expect(results[0]).toMatchObject({
start: '2024-11-23T23:30:00.000Z',
stop: '2024-11-24T00:15:00.000Z',
title: 'FBI: Most Wanted S4, Ep 18',
description:
'Satgas Buronan pergi ke wilayah barat untuk melacak keberadaan dua petugas Biro Pengelolaan Lahan yang menghilang saat menjalankan perintah penyitaan lahan di negara bagian yang tak ramah, Wyoming.',
season: 4,
episode: 18
})
})
it('can handle empty guide', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
const results = parser({ content, channel })
expect(results).toMatchObject([])
})