mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create mojmaxtv.hrvatskitelekom.hr.test.js
This commit is contained in:
parent
f1eddf579e
commit
524846fefb
1 changed files with 89 additions and 0 deletions
|
@ -0,0 +1,89 @@
|
||||||
|
const { parser, url, request } = require('./mojmaxtv.hrvatskitelekom.hr.config.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const axios = require('axios')
|
||||||
|
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('2025-01-24', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = { site_id: '274913832105', xmltv_id: 'HRT1.hr' }
|
||||||
|
|
||||||
|
jest.mock('axios')
|
||||||
|
|
||||||
|
axios.get.mockImplementation(url => {
|
||||||
|
if (
|
||||||
|
url ===
|
||||||
|
'https://tv-hr-prod.yo-digital.com/hr-bifrost/epg/channel/schedules?date=2025-01-24&hour_offset=3&hour_range=3&channelMap_id&filler=true&app_language=hr&natco_code=hr'
|
||||||
|
) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/content_3.json')))
|
||||||
|
})
|
||||||
|
} else if (
|
||||||
|
url ===
|
||||||
|
'https://tv-hr-prod.yo-digital.com/hr-bifrost/epg/channel/schedules?date=2025-01-24&hour_offset=21&hour_range=3&channelMap_id&filler=true&app_language=hr&natco_code=hr'
|
||||||
|
) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/content_21.json')))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ date })).toBe(
|
||||||
|
'https://tv-hr-prod.yo-digital.com/hr-bifrost/epg/channel/schedules?date=2025-01-24&hour_offset=0&hour_range=3&channelMap_id&filler=true&app_language=hr&natco_code=hr'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid request headers', () => {
|
||||||
|
expect(request.headers).toMatchObject({
|
||||||
|
app_key: 'GWaBW4RTloLwpUgYVzOiW5zUxFLmoMj5',
|
||||||
|
app_version: '02.0.1080',
|
||||||
|
'device-id': 'a78f079d-5527-46d8-af3f-9f0b6b6fb758',
|
||||||
|
'x-request-session-id': 'fc96c9de-7a3b-4b51-8b9d-5d9f9a3c3268',
|
||||||
|
'x-request-tracking-id': '05a8f0bc-f977-4754-b8ad-1d4d1bd742fb',
|
||||||
|
'x-user-agent': 'web|web|Chrome-128|02.0.1080|1'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', async () => {
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content_0.json'))
|
||||||
|
|
||||||
|
const results = await parser({ content, channel, date })
|
||||||
|
|
||||||
|
expect(results.length).toBe(17)
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
title: 'Planet Zemlja: Junaci',
|
||||||
|
categories: ['Dokumentarni'],
|
||||||
|
season: 3,
|
||||||
|
episode: 8,
|
||||||
|
date: '2023',
|
||||||
|
start: '2025-01-23T23:16:00.00Z',
|
||||||
|
stop: '2025-01-24T00:08:00.00Z'
|
||||||
|
})
|
||||||
|
expect(results[16]).toMatchObject({
|
||||||
|
title: 'Harry Haft, film',
|
||||||
|
categories: ['Film', 'Drama', 'Biografski'],
|
||||||
|
season: null,
|
||||||
|
episode: null,
|
||||||
|
date: '2021',
|
||||||
|
start: '2025-01-24T21:50:00.00Z',
|
||||||
|
stop: '2025-01-25T00:00:00.00Z'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', async () => {
|
||||||
|
const results = await parser({
|
||||||
|
date,
|
||||||
|
channel,
|
||||||
|
content: '{}'
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(results).toMatchObject([])
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue