mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update dishtv.in.test.js
This commit is contained in:
parent
9ec69b31b1
commit
db94809828
1 changed files with 120 additions and 22 deletions
|
@ -1,42 +1,140 @@
|
|||
const { parser, url, request } = require('./dishtv.in.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('2021-11-05', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: '10000000075992337', xmltv_id: 'WomensActive.in' }
|
||||
const content =
|
||||
'{"d":"\\u003cdiv class=\\"pgrid\\"\\u003e\\u003cdiv class=\\"img sm-30 grid\\"\\u003e\\u003cimg class=\\"chnl-logo\\" src=\\"http://imagesdishtvd2h.whatsonindia.com/dasimages/channel/landscape/360x270/hiyj8ndf.png\\" onclick=\\"ShowChannelGuid(\\u0027womens-active\\u0027,\\u002710000000075992337\\u0027);\\" /\\u003e\\u003cdiv class=\\"cnl-fav\\"\\u003e\\u003ca href=\\"javascript:;\\"\\u003e\\u003cem\\u003ech. no\\u003c/em\\u003e\\u003cspan\\u003e117\\u003c/span\\u003e\\u003c/a\\u003e\\u003c/div\\u003e\\u003ci class=\\"fa fa-heart Set_Favourite_Channel\\" aria-hidden=\\"true\\" title=\\"Set womens active channel as your favourite channel\\" onclick=\\"SetFavouriteChannel();\\"\\u003e\\u003c/i\\u003e\\u003c/div\\u003e\\u003cdiv class=\\"grid-wrap\\"\\u003e\\u003cdiv class=\\"sm-30 grid datatime\\" data-time=\\"24\\" data-starttime=\\"12:00 AM\\" data-endttime=\\"12:24 AM\\" data-reamintime=\\"0\\"\\u003e\\u003ca title=\\"Event Name: Cynthia Williams - Diwali Look Part 01\\r\\nStart Time: 12:00 AM\\r\\nDuration: 24min\\r\\nSynopsis: Learn diwali look by cynthia williams p1\\r\\n\\" href=\\"javascript:;\\" onclick=\\"ShowCurrentTime(\\u002730000000550913679\\u0027,\\u002710000000075992337\\u0027,\\u0027202111051200\\u0027)\\"\\u003eCynthia Williams - Diwali Look Part 01\\u003c/a\\u003e\\u003cdiv class=\\"cnlSerialIcon\\"\\u003e\\u003ci class=\\"fa fa-heart\\" aria-hidden=\\"true\\" title=\\"Set Favourite Serial\\" onclick=\\"SetFavouriteShow();\\"\\u003e\\u003c/i\\u003e\\u003ci class=\\"fa fa-clock-o\\" aria-hidden=\\"true\\" title=\\"Reminder Serial\\" onclick=\\"ReminderEnteryOpen(\\u002730000000550913679\\u0027,\\u002710000000075992337\\u0027,\\u0027202111050000\\u0027,\\u0027117\\u0027)\\"\\u003e\\u003c/i\\u003e\\u003ci class=\\"fa fa-circle\\" aria-hidden=\\"true\\" title=\\"Record Serial\\" onclick=\\"RecordingEnteryOpen(\\u002730000000550913679\\u0027,\\u002710000000075992337\\u0027,\\u0027202111050000\\u0027,\\u0027117\\u0027,30000000550913679)\\"\\u003e\\u003c/i\\u003e\\u003c/div\\u003e\\u003c/div\\u003e\\u003c/div\\u003e\\u003c/div\\u003e"}'
|
||||
jest.mock('axios')
|
||||
|
||||
axios.post.mockImplementation((url, data, params) => {
|
||||
if (
|
||||
url === 'https://www.dishtv.in/services/epg/signin' &&
|
||||
data === null &&
|
||||
JSON.stringify(params) ===
|
||||
JSON.stringify({
|
||||
headers: {
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
Referer: 'https://www.dishtv.in/channel-guide.html'
|
||||
}
|
||||
})
|
||||
) {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/session.json'))
|
||||
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(content)
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({
|
||||
data: ''
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const date = dayjs.utc('2025-01-26', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: '142639', xmltv_id: 'AndpriveHD.in' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe(
|
||||
'https://www.dishtv.in/WhatsonIndiaWebService.asmx/LoadPagginResultDataForProgram'
|
||||
)
|
||||
expect(url).toBe('https://epg.mysmartstick.com/dishtv/api/v1/epg/entities/programs')
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', async () => {
|
||||
expect(await request.headers()).toMatchObject({
|
||||
Authorization:
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRpZCI6ImRpc2h0di13ZWJzaXRlIiwicGxhdGZvcm0iOiJkaXNodHYiLCJpYXQiOjE3Mzc2ODIxNjEsImV4cCI6MTczNzc2ODU2MX0.sPrYfodVTbf1kJ-wGICDlnH-Yt3J0-mB-M2YROU8v2Q'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
const result = request.data({ channel, date })
|
||||
expect(result).toMatchObject({
|
||||
Channelarr: '10000000075992337',
|
||||
fromdate: '202111050000',
|
||||
todate: '202111060000'
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
allowPastEvents: true,
|
||||
channelid: '142639',
|
||||
date: '26/01/2025'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: 'Thu, 04 Nov 2021 18:30:00 GMT',
|
||||
stop: 'Thu, 04 Nov 2021 18:54:00 GMT',
|
||||
title: 'Cynthia Williams - Diwali Look Part 01'
|
||||
}
|
||||
])
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(16)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-26T00:30:00.000Z',
|
||||
stop: '2025-01-26T02:05:00.000Z',
|
||||
title: [
|
||||
{ lang: 'en', value: 'Train to Busan 2: Peninsula' },
|
||||
{ lang: 'hi', value: 'ट्रेन टू बुसान 2: पेनीनसुला' },
|
||||
{ lang: 'ta', value: 'ட்ரெயின் டு பூசன் ப்ரெசென்ட்ஸ்: பெனின்சுலா' },
|
||||
{ lang: 'te', value: 'ట్రేన్ టు బూసాన్ ప్రజెంట్స్: పెనిన్సులా' }
|
||||
],
|
||||
description: [
|
||||
{
|
||||
lang: 'en',
|
||||
value:
|
||||
'Jung Seok, a former soldier, along with his teammates, sets out on a mission to battle hordes of post-apocalyptic zombies in the Korean peninsula wastelands.'
|
||||
},
|
||||
{
|
||||
lang: 'hi',
|
||||
value:
|
||||
'एक भूतपूर्व सैनिक जंग सोक अपने साथियों के साथ कोरियाई प्रायद्वीप के बंजर इलाकों में सर्वनाश के बाद की जोंबी से लड़ने के मिशन पर निकलता है।'
|
||||
},
|
||||
{
|
||||
lang: 'ta',
|
||||
value:
|
||||
'கொரிய தீபகற்பத்தின் தரிசு நிலங்களில் அபோகாலிப்டிக் ஜாம்பிக்களின் கூட்டத்தை எதிர்த்து தன் குழுவுடன் போரிடும் ஜங் சியோக்.'
|
||||
},
|
||||
{
|
||||
lang: 'te',
|
||||
value:
|
||||
'మాజీ సైనికుడు జంగ్ సియోక్ తన సహచరులతో కలిసి కొరియా ద్వీపకల్పంలో పోస్ట్-అపోకలిప్టిక్ జాంబీలతో యుద్దానికి సిద్దమవుతాడు.'
|
||||
}
|
||||
],
|
||||
category: [
|
||||
{ lang: 'en', value: 'Film' },
|
||||
{ lang: 'hi', value: 'फ़िल्म' },
|
||||
{ lang: 'ta', value: '??????????' },
|
||||
{ lang: 'te', value: 'సినిమా' },
|
||||
{ lang: 'mr', value: 'चित्रपट' }
|
||||
],
|
||||
actors: [
|
||||
'Gang Dong-won',
|
||||
'Lee Jung-hyun',
|
||||
'Lee Re',
|
||||
'Kwon Hae-hyo',
|
||||
'John D. Michaels',
|
||||
'Kim Min-jae',
|
||||
'Kim Doyun',
|
||||
'Lee Ye-won',
|
||||
'Daniel Joey Albright',
|
||||
'Pierce Conran',
|
||||
'Geoffrey Giuliano',
|
||||
'Milan-Devi LaBrey'
|
||||
],
|
||||
producers: [],
|
||||
directors: ['Yeon Sang-ho'],
|
||||
icon: 'https://dtil.tmsimg.com/assets/p17850257_v_h9_al.jpg?lock=880x660',
|
||||
image: 'https://dtil.tmsimg.com/assets/p17850257_v_h8_am.jpg?lock=1280x720',
|
||||
date: '2020'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ date, channel, content: '{"d":""}' })
|
||||
expect(result).toMatchObject([])
|
||||
const results = parser({ content: '[]' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue