mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Create opto.sic.pt.test.js
This commit is contained in:
parent
54ec0074a4
commit
cb1921d008
1 changed files with 52 additions and 0 deletions
52
sites/opto.sic.pt/opto.sic.pt.test.js
Normal file
52
sites/opto.sic.pt/opto.sic.pt.test.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
const { parser, url } = require('./opto.sic.pt.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('2025-01-17', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '38719848-2a57-42e3-8640-63a9aa39f107',
|
||||
xmltv_id: 'SICNoticias.pt'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ date, channel })).toBe(
|
||||
'https://opto.sic.pt/api/v1/content/epg?startDate=1737072000&endDate=1737158400&channels=38719848-2a57-42e3-8640-63a9aa39f107'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
|
||||
let results = parser({ content })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(17)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-17T00:00:00.000Z',
|
||||
stop: '2025-01-17T01:45:00.000Z',
|
||||
title: 'JORNAL DA MEIA-NOITE',
|
||||
episode: 16,
|
||||
season: null
|
||||
})
|
||||
expect(results[16]).toMatchObject({
|
||||
start: '2025-01-17T23:00:00.000Z',
|
||||
stop: '2025-01-18T00:00:00.000Z',
|
||||
title: 'EXPRESSO DA MEIA-NOITE',
|
||||
episode: 2,
|
||||
season: null
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue