mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update beinsports.com.test.js
Updating beinsports.com test.js to use new api end point
This commit is contained in:
parent
5d68c721d4
commit
bc7f5da9f9
1 changed files with 17 additions and 59 deletions
|
@ -11,81 +11,39 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
const date = dayjs.utc('2022-05-08', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2023-10-22T00:00:00.000', '"YYYY-MM-DDTHH:mm:ss.SSS').startOf('d')
|
||||||
const channel = { site_id: '#2', xmltv_id: 'BeINSports.qa' }
|
const channel = { site_id: 'C244C48D-3B54-406A-94C9-D63B16318267', xmltv_id: 'beINSportsUSA.us' }
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
const result = url({ date, channel })
|
const result = url({ date, channel })
|
||||||
expect(result).toBe(
|
expect(result).toBe(
|
||||||
'https://epg.beinsports.com/utctime.php?mins=00&serviceidentity=beinsports.com&cdate=2022-05-08'
|
'https://www.beinsports.com/api/opta/tv-event?&startBefore=2023-10-23T00:00:00.000Z&endAfter=2023-10-22T00:00:00.000Z&channelIds=C244C48D-3B54-406A-94C9-D63B16318267'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can generate valid url for arabic guide', () => {
|
const content ='{"count":1,"rows":[{"data":{"eventId":"2028126","eventDate":"2023-10-21T10:30:00","utcEventDate":"2023-10-20T23:30:00","duration":"90","programId":"106230","programTypeId":"5","title":"ATP 500"},"duration":5400000,"title":"Tokyo Day 5 QF 2","startDate":"2023-10-20T23:30:00.000Z","endDate":"2023-10-21T01:00:00.000Z","description":"Exclusive coverage of the 2023 ATP Tour on beIN SPORTS","channelId":"164C0EDA-EBCE-4AA6-9DDA-D603E0948B9F"}]}'
|
||||||
const channel = { site_id: 'ar#1', xmltv_id: 'BeINSports.qa' }
|
|
||||||
const result = url({ date, channel })
|
|
||||||
expect(result).toBe(
|
|
||||||
'https://epg.beinsports.com/utctime_ar.php?mins=00&serviceidentity=beinsports.com&cdate=2022-05-08'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
const content = fs.readFileSync(path.resolve('sites/beinsports.com/__data__/content.html'))
|
const result = parser({ content, channel, date }).map(p => {
|
||||||
const results = parser({ date, channel, content }).map(p => {
|
|
||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(results[0]).toMatchObject({
|
expect(result).toMatchObject([
|
||||||
start: '2022-05-07T19:30:00.000Z',
|
{
|
||||||
stop: '2022-05-07T21:20:00.000Z',
|
start: '2023-10-20T23:30:00.000Z',
|
||||||
title: 'Lorient vs Marseille',
|
stop: '2023-10-21T01:00:00.000Z',
|
||||||
category: ['Ligue 1 2021/22']
|
title: 'Tokyo Day 5 QF 2',
|
||||||
})
|
description: 'Exclusive coverage of the 2023 ATP Tour on beIN SPORTS'
|
||||||
})
|
}
|
||||||
|
])
|
||||||
it('can parse response for tomorrow', () => {
|
|
||||||
const date = dayjs.utc('2022-05-09', 'YYYY-MM-DD').startOf('d')
|
|
||||||
const content = fs.readFileSync(
|
|
||||||
path.resolve('sites/beinsports.com/__data__/content_tomorrow.html')
|
|
||||||
)
|
|
||||||
const results = parser({ date, channel, content }).map(p => {
|
|
||||||
p.start = p.start.toJSON()
|
|
||||||
p.stop = p.stop.toJSON()
|
|
||||||
return p
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(results[0]).toMatchObject({
|
|
||||||
start: '2022-05-08T21:20:00.000Z',
|
|
||||||
stop: '2022-05-08T23:10:00.000Z',
|
|
||||||
title: 'Celtic vs Hearts',
|
|
||||||
category: ['SPFL Premiership 2021/22']
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can parse US response', () => {
|
|
||||||
const content = fs.readFileSync(path.resolve('sites/beinsports.com/__data__/content_us.html'))
|
|
||||||
const results = parser({ date, channel, content }).map(p => {
|
|
||||||
p.start = p.start.toJSON()
|
|
||||||
p.stop = p.stop.toJSON()
|
|
||||||
return p
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(results[0]).toMatchObject({
|
|
||||||
start: '2022-05-07T20:00:00.000Z',
|
|
||||||
stop: '2022-05-07T22:00:00.000Z',
|
|
||||||
title: 'Basaksehir vs. Galatasaray',
|
|
||||||
category: ['Fútbol Turco Superliga', 'Soccer']
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', () => {
|
||||||
const noContent = fs.readFileSync(path.resolve('sites/beinsports.com/__data__/no-content.html'))
|
|
||||||
const result = parser({
|
const result = parser({
|
||||||
date,
|
content: '[]'
|
||||||
channel,
|
|
||||||
content: noContent
|
|
||||||
})
|
})
|
||||||
expect(result).toMatchObject([])
|
expect(result).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue