mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Create cyta.com.cy.test.js
This commit is contained in:
52
sites/cyta.com.cy/cyta.com.cy.test.js
Normal file
52
sites/cyta.com.cy/cyta.com.cy.test.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const { url, parser } = require('./cyta.com.cy.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
const date = dayjs.utc('2025-01-03', 'YYYY-MM-DD').startOf('day')
|
||||
const channel = {
|
||||
site_id: '561066',
|
||||
xmltv_id: 'RIK1.cy'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const generatedUrl = url({ date, channel })
|
||||
console.log('Generated URL:', generatedUrl)
|
||||
expect(generatedUrl).toBe('https://epg.cyta.com.cy/api/mediacatalog/fetchEpg?startTimeEpoch=1735862400000&endTimeEpoch=1735948800000&language=1&channelIds=561066')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `
|
||||
{
|
||||
"channelEpgs": [
|
||||
{
|
||||
"epgPlayables": [
|
||||
{ "name": "Πρώτη Ενημέρωση", "startTime": 1735879500000, "endTime": 1735889400000 }
|
||||
]
|
||||
}
|
||||
]
|
||||
}`
|
||||
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start
|
||||
p.stop = p.stop
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: "Πρώτη Ενημέρωση",
|
||||
start: "2025-01-03T04:45:00.000Z",
|
||||
stop: "2025-01-03T07:30:00.000Z"
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '{"channelEpgs":[]}'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
Reference in New Issue
Block a user