mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Create winplay.co.test.js
This commit is contained in:
parent
ff84be91f8
commit
770b9c856d
1 changed files with 68 additions and 0 deletions
68
sites/winplay.co/winplay.co.test.js
Normal file
68
sites/winplay.co/winplay.co.test.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
const { parser, url, request } = require('./winplay.co.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('2024-12-24', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '529cff6f6bd2ea6b610000e0',
|
||||
xmltv_id: 'WinPlusFutbol.co'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://next.platform.mediastre.am/graphql')
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
expect(request.headers).toMatchObject({
|
||||
accept: 'application/json',
|
||||
'x-client-id': 'a084524ea449c15dfe5e75636fb55ce6a9d0d7601aac946daa',
|
||||
'x-ott-language': 'es'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data()).toMatchObject({
|
||||
operationName: 'getLivesEpg',
|
||||
variables: { page: 1, hours: 48 },
|
||||
query:
|
||||
'query getLivesEpg($page: Int = 1, $hours: Int, $ids: [String]) {\n getLives(ids: $ids) {\n _id\n logo\n name\n schedules(hours: $hours, page: {limit: 0, page: $page}) {\n _id\n name\n date_start\n date_end\n current\n match {\n matchDay\n __typename\n }\n show {\n _id\n title\n __typename\n }\n live {\n _id\n dvr\n type\n purchased\n __typename\n }\n __typename\n }\n __typename\n }\n}\n'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
|
||||
|
||||
const results = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2024-12-24T00:30:00.000Z',
|
||||
stop: '2024-12-24T02:30:00.000Z',
|
||||
title: 'Los Disruptivos de Win'
|
||||
})
|
||||
|
||||
expect(results[1]).toMatchObject({
|
||||
start: '2024-12-24T02:30:00.000Z',
|
||||
stop: '2024-12-24T03:30:00.000Z',
|
||||
title: 'WIn Noticias'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = '{"status":"ERROR","error":"UNAUTHORIZED_REQUEST"}'
|
||||
const results = parser({ content, channel, date })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue