mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Create canalplus-afrique.com.test.js
This commit is contained in:
parent
c9e6b8135b
commit
71b6ac14d8
1 changed files with 60 additions and 0 deletions
60
sites/canalplus-afrique.com/canalplus-afrique.com.test.js
Normal file
60
sites/canalplus-afrique.com/canalplus-afrique.com.test.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
// [Geo-blocked] node ./scripts/commands/parse-channels.js --config=./sites/canalplus-afrique.com/canalplus-afrique.com.config.js --output=./sites/canalplus-afrique.com/canalplus-afrique.com_bf.channels.xml --set=country:bf
|
||||
// npx epg-grabber --config=sites/canalplus-afrique.com/canalplus-afrique.com.config.js --channels=sites/canalplus-afrique.com/canalplus-afrique.com_bf.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, logo } = require('./canalplus-afrique.com.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const channel = {
|
||||
site_id: '60020',
|
||||
xmltv_id: 'CanalPlusReunion.fr',
|
||||
logo: 'https://service.canal-overseas.com/image-api/v1/image/702e588188caa19c38c438d14bfc8870'
|
||||
}
|
||||
|
||||
it('can generate valid url for today', () => {
|
||||
const date = dayjs.utc().startOf('d')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/83001/channel/60020/events?filter.day=0'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate valid url for tomorrow', () => {
|
||||
const date = dayjs.utc().startOf('d').add(1, 'd')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/83001/channel/60020/events?filter.day=1'
|
||||
)
|
||||
})
|
||||
|
||||
it('can get logo url', () => {
|
||||
expect(logo({ channel })).toBe(
|
||||
'https://service.canal-overseas.com/image-api/v1/image/702e588188caa19c38c438d14bfc8870'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{"timeSlices":[{"contents":[{"title":"Fin des programmes","thirdTitle":"MA TV","startTime":1636768800,"endTime":1636855200,"onClick":{"displayTemplate":"miniDetail","displayName":"Fin des programmes","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427432","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/0/recommendations"},"programID":0,"diffusionID":"110427432","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/generic","URLImage":"https://service.canal-overseas.com/image-api/v1/image/generic"}],"timeSlice":"0"},{"contents":[{"title":"Le cercle","subtitle":"5 Novembre 2021","thirdTitle":"CANAL+ HD","startTime":1636793201,"endTime":1636795901,"onClick":{"displayTemplate":"miniDetail","displayName":"Le cercle","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427540","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/193072081/recommendations"},"programID":193072081,"diffusionID":"110427540","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7","URLImage":"https://service.canal-overseas.com/image-api/v1/image/2de336e6a8c962921638c8aeee5f7e52"}],"timeSlice":"1"},{"contents":[],"timeSlice":"2"},{"contents":[],"timeSlice":"3"},{"contents":[],"timeSlice":"4"}]}`
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-13T08:46:41.000Z',
|
||||
stop: '2021-11-13T09:31:41.000Z',
|
||||
title: 'Le cercle',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue