uniformise tests part 1

This commit is contained in:
theofficialomega
2025-07-12 13:24:07 +02:00
parent be7db6a324
commit 12849d2350
14 changed files with 5259 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html><head></head><body></body></html>

View File

@@ -86,7 +86,7 @@ it('can handle empty guide', async () => {
const result = await parser({
date,
channel,
content: '<!DOCTYPE html><html><head></head><body></body></html>'
content: fs.readFileSync(path.resolve(__dirname, '__data__', 'no_content.html'), 'utf8')
})
expect(result).toMatchObject([])
})

View File

@@ -0,0 +1,54 @@
{
"entries":[
{
"channelId":1000259,
"startTimestamp":"1637283000000",
"endTimestamp":"1637284500000",
"name":"Dnevnik Slovencev v Italiji",
"nameSingleLine":"Dnevnik Slovencev v Italiji",
"description":"Informativni",
"images":[
{
"url":"/static/media/img/epg/max_crop/EPG_IMG_2927405.jpg",
"width":1008,
"height":720,
"averageColor":[
143,
147,
161
]
}
],
"show":{
"id":51991133,
"title":"Dnevnik Slovencev v Italiji",
"originalTitle":"Dnevnik Slovencev v Italiji",
"shortDescription":"Dnevnik Slovencev v Italiji je informativna oddaja, v kateri novinarji poročajo predvsem o dnevnih dogodkih med Slovenci v Italiji.",
"longDescription":"Pomembno ogledalo vsakdana, v katerem opozarjajo na težave, s katerimi se soočajo, predstavljajo pa tudi pestro kulturno, športno in družbeno življenje slovenske narodne skupnosti. V oddajo so vključene tudi novice iz matične domovine.",
"type":{
"id":10,
"name":"Show"
},
"productionFrom":"1609502400000",
"countries":[
{
"id":"SI",
"name":"Slovenija"
}
],
"languages":[
{
"languageId":2,
"name":"Slovenščina"
}
],
"genres":[
{
"id":1000002,
"name":"Informativni"
}
]
}
}
]
}

View File

@@ -1,5 +1,7 @@
const { parser, url, request } = require('./tv2go.t-2.net.config.js')
const dayjs = require('dayjs')
const fs = require('fs')
const path = require('path')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
@@ -36,8 +38,7 @@ it('can generate valid request data', () => {
})
it('can parse response', () => {
const content =
'{"entries":[{"channelId":1000259,"startTimestamp":"1637283000000","endTimestamp":"1637284500000","name":"Dnevnik Slovencev v Italiji","nameSingleLine":"Dnevnik Slovencev v Italiji","description":"Informativni","images":[{"url":"/static/media/img/epg/max_crop/EPG_IMG_2927405.jpg","width":1008,"height":720,"averageColor":[143,147,161]}],"show":{"id":51991133,"title":"Dnevnik Slovencev v Italiji","originalTitle":"Dnevnik Slovencev v Italiji","shortDescription":"Dnevnik Slovencev v Italiji je informativna oddaja, v kateri novinarji poročajo predvsem o dnevnih dogodkih med Slovenci v Italiji.","longDescription":"Pomembno ogledalo vsakdana, v katerem opozarjajo na težave, s katerimi se soočajo, predstavljajo pa tudi pestro kulturno, športno in družbeno življenje slovenske narodne skupnosti. V oddajo so vključene tudi novice iz matične domovine.","type":{"id":10,"name":"Show"},"productionFrom":"1609502400000","countries":[{"id":"SI","name":"Slovenija"}],"languages":[{"languageId":2,"name":"Slovenščina"}],"genres":[{"id":1000002,"name":"Informativni"}]}}]}'
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.json'), 'utf8')
const result = parser({ content, channel }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html><head></head><body></body></html>

View File

@@ -44,7 +44,7 @@ it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: '<!DOCTYPE html><html><head></head><body></body></html>'
content: fs.readFileSync(path.resolve(__dirname, './__data__/no_content.html'), 'utf8')
})
expect(result).toMatchObject([])
})

View File

@@ -0,0 +1,55 @@
[
{
"eventId":"6169c2300ad38b0a8d9e3760",
"title":"CARIBE NOTICIAS",
"description":"EMISI\\u00d3N DE CIERRE.",
"eventInitialDate":"2021-11-22T00:00:00",
"eventEndDate":"2021-11-22T00:00:00",
"idFromEprog":"5c096ea5bad1b202541503cf",
"extendedDescription":"",
"transmission":"Estreno",
"pid":"",
"space":"CARIBE NOTICIAS",
"eventStartTime":{
"value":{
"ticks":24000000000,
"days":0,
"hours":0,
"milliseconds":0,
"minutes":40,
"seconds":0,
"totalDays":0.027777777777777776,
"totalHours":0.6666666666666666,
"totalMilliseconds":2400000,
"totalMinutes":40,
"totalSeconds":2400
},
"hasValue":true
},
"eventEndTime":{
"value":{
"ticks":30000000000,
"days":0,
"hours":0,
"milliseconds":0,
"minutes":50,
"seconds":0,
"totalDays":0.034722222222222224,
"totalHours":0.8333333333333334,
"totalMilliseconds":3000000,
"totalMinutes":50,
"totalSeconds":3000
},
"hasValue":true
},
"eventDuration":"00:10:00",
"channelName":"Cubavisi\\u00f3n",
"eventInitialDateTime":"2021-11-22T00:40:00",
"eventEndDateTime":"2021-11-22T00:50:00",
"isEventWithNegativeDuration":false,
"isEventWithDurationOver24Hrs":false,
"isEventWithTextOverLength":false,
"created":"2021-11-22T10:32:27.476824",
"id":5309687
}
]

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html lang="es-es" dir="ltr"><head></head><body class="error-page" ></body></html>

View File

@@ -1,5 +1,7 @@
const { parser, url } = require('./tvcubana.icrt.cu.config.js')
const dayjs = require('dayjs')
const fs = require('fs')
const path = require('path')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
@@ -10,8 +12,9 @@ const channel = {
site_id: 'cv',
xmltv_id: 'CubavisionNacional.cu'
}
const content =
'[{"eventId":"6169c2300ad38b0a8d9e3760","title":"CARIBE NOTICIAS","description":"EMISI\\u00d3N DE CIERRE.","eventInitialDate":"2021-11-22T00:00:00","eventEndDate":"2021-11-22T00:00:00","idFromEprog":"5c096ea5bad1b202541503cf","extendedDescription":"","transmission":"Estreno","pid":"","space":"CARIBE NOTICIAS","eventStartTime":{"value":{"ticks":24000000000,"days":0,"hours":0,"milliseconds":0,"minutes":40,"seconds":0,"totalDays":0.027777777777777776,"totalHours":0.6666666666666666,"totalMilliseconds":2400000,"totalMinutes":40,"totalSeconds":2400},"hasValue":true},"eventEndTime":{"value":{"ticks":30000000000,"days":0,"hours":0,"milliseconds":0,"minutes":50,"seconds":0,"totalDays":0.034722222222222224,"totalHours":0.8333333333333334,"totalMilliseconds":3000000,"totalMinutes":50,"totalSeconds":3000},"hasValue":true},"eventDuration":"00:10:00","channelName":"Cubavisi\\u00f3n","eventInitialDateTime":"2021-11-22T00:40:00","eventEndDateTime":"2021-11-22T00:50:00","isEventWithNegativeDuration":false,"isEventWithDurationOver24Hrs":false,"isEventWithTextOverLength":false,"created":"2021-11-22T10:32:27.476824","id":5309687}]'
let content = fs.readFileSync(path.resolve(__dirname, './__data__/content.json'), {encoding: 'utf8'})
// in the specific case of this site, the unicode escape sequences are double-escaped
content = content.replace(/\\\\u([0-9a-fA-F]{4})/g, '\\u$1')
it('can generate valid url', () => {
expect(url({ channel, date })).toBe('https://www.tvcubana.icrt.cu/cartv/cv/lunes.php')
@@ -43,8 +46,7 @@ it('can handle empty guide', () => {
const result = parser({
date,
channel,
content:
'<!DOCTYPE html><html lang="es-es" dir="ltr"><head></head><body class="error-page" ></body></html>'
content: fs.readFileSync(path.resolve(__dirname, './__data__/no_content.html'), 'utf8')
})
expect(result).toMatchObject([])
})

View File

@@ -0,0 +1,34 @@
{
"120_200_4_20220114":[
{
"@search.score":1,
"cid":"120_7305523",
"serviceCode":"200_4",
"channelName":"スターチャンネル1",
"digitalNo":195,
"eventId":"181",
"title":"[5.1]フードロア:タマリンド",
"commentary":"HBO(R)アジア製作。日本の齊藤工などアジアの監督が、各国の食をテーマに描いたアンソロジーシリーズ。(全8話)(19年 シンガポール 56分)",
"attr":[
"5.1",
"hd",
"cp1"
],
"sortGenre":"31",
"hasImage":1,
"imgPath":"/monomedia/si/2022/20220114/7305523/image/7743d17b655b8d2274ca58b74f2f095c.jpg",
"isRecommended":null,
"programStart":20220114050000,
"programEnd":20220114060000,
"programDate":20220114,
"programId":568519,
"start_time":"00",
"duration":60,
"top":300,
"end_time":"20220114060000",
"channel_type":"120",
"is_end":false,
"show_remoterec":true
}
]
}

View File

@@ -0,0 +1 @@
{"120_200_3_20220114":[]}

View File

@@ -1,5 +1,7 @@
const { parser, url } = require('./tvguide.myjcom.jp.config.js')
const dayjs = require('dayjs')
const fs = require('fs')
const path = require('path')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
@@ -11,8 +13,7 @@ const channel = {
name: 'Star Channel 1',
xmltv_id: 'StarChannel1.jp'
}
const content =
'{"120_200_4_20220114":[{"@search.score":1,"cid":"120_7305523","serviceCode":"200_4","channelName":"スターチャンネル1","digitalNo":195,"eventId":"181","title":"[5.1]フードロア:タマリンド","commentary":"HBO(R)アジア製作。日本の齊藤工などアジアの監督が、各国の食をテーマに描いたアンソロジーシリーズ。(全8話)(19年 シンガポール 56分)","attr":["5.1","hd","cp1"],"sortGenre":"31","hasImage":1,"imgPath":"/monomedia/si/2022/20220114/7305523/image/7743d17b655b8d2274ca58b74f2f095c.jpg","isRecommended":null,"programStart":20220114050000,"programEnd":20220114060000,"programDate":20220114,"programId":568519,"start_time":"00","duration":60,"top":300,"end_time":"20220114060000","channel_type":"120","is_end":false,"show_remoterec":true}]}'
const content = fs.readFileSync(path.resolve(__dirname, './__data__/content.json'), 'utf8')
it('can generate valid url', () => {
const result = url({ date, channel })
@@ -44,7 +45,7 @@ it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: '{"120_200_3_20220114":[]}'
content: fs.readFileSync(path.resolve(__dirname, './__data__/no_content.json'), 'utf8')
})
expect(result).toMatchObject([])
})

View File

@@ -1,5 +1,6 @@
const { parser, url } = require('./tvheute.at.config.js')
const dayjs = require('dayjs')
const path = require('path')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
const { readFileSync } = require('fs')
@@ -16,7 +17,7 @@ it('can generate valid url', () => {
})
it('can parse response', () => {
expect(parser({ date, channel, content: readFileSync('./__data__/content.html', 'utf8') })).toMatchObject([
expect(parser({ date, channel, content: readFileSync(path.resolve(__dirname, './__data__/content.html'), 'utf8') })).toMatchObject([
{
start: '2021-11-08T05:00:00.000Z',
stop: '2021-11-08T05:10:00.000Z',
@@ -38,7 +39,7 @@ it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: readFileSync('./__data__/no_content.html', 'utf8')
content: readFileSync(path.resolve(__dirname, './__data__/no_content.html'), 'utf8')
})
expect(result).toMatchObject([])
})