mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Create rikstv.no.test.js
This commit is contained in:
parent
48bae7af1f
commit
46f8f41d84
1 changed files with 66 additions and 0 deletions
66
sites/rikstv.no/rikstv.no.test.js
Normal file
66
sites/rikstv.no/rikstv.no.test.js
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
const { parser, url } = require('./rikstv.no.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 date = dayjs.utc('2025-01-14', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = {
|
||||||
|
site_id: '47',
|
||||||
|
xmltv_id: 'NRK1.no'
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('rikstv.no Module Tests', () => {
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ date, channel })).toBe(`https://play.rikstv.no/api/content-search/1/channel/${channel.site_id}/epg/${date.format('YYYY-MM-DD')}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = JSON.stringify([
|
||||||
|
{
|
||||||
|
seriesName: 'Vakre og ville Oman',
|
||||||
|
name: 'Vakre og ville Oman',
|
||||||
|
description: 'Oman er eit arabisk skattkammer av unike habitat og variert dyreliv. Rev, kvalhai, reptil og skjelpadder er blant skapningane du finn her.',
|
||||||
|
season: 1,
|
||||||
|
episode: 1,
|
||||||
|
genres: ['Dokumentar', 'Fakta', 'Natur'],
|
||||||
|
actors: ['Gergana Muskalla'],
|
||||||
|
director: 'Stefania Muller',
|
||||||
|
imagePackUri: 'https://imageservice.rikstv.no/hash/EC206C374F42287C0BDF850A7D3CB4D3.jpg',
|
||||||
|
broadcastedTime: '2025-01-13T23:00:00Z',
|
||||||
|
broadcastedTimeEnd: '2025-01-13T23:55:00Z'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const result = parser({ content }).map(p => {
|
||||||
|
p.start = dayjs(p.start).toISOString()
|
||||||
|
p.stop = dayjs(p.stop).toISOString()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(result).toMatchObject([
|
||||||
|
{
|
||||||
|
title: 'Vakre og ville Oman',
|
||||||
|
sub_title: 'Vakre og ville Oman',
|
||||||
|
description: 'Oman er eit arabisk skattkammer av unike habitat og variert dyreliv. Rev, kvalhai, reptil og skjelpadder er blant skapningane du finn her.',
|
||||||
|
season: 1,
|
||||||
|
episode: 1,
|
||||||
|
category: ['Dokumentar', 'Fakta', 'Natur'],
|
||||||
|
actors: ['Gergana Muskalla'],
|
||||||
|
directors: 'Stefania Muller',
|
||||||
|
icon: 'https://imageservice.rikstv.no/hash/EC206C374F42287C0BDF850A7D3CB4D3.jpg',
|
||||||
|
start: '2025-01-13T23:00:00.000Z',
|
||||||
|
stop: '2025-01-13T23:55:00.000Z'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const result = parser({
|
||||||
|
content: '[]'
|
||||||
|
})
|
||||||
|
expect(result).toMatchObject([])
|
||||||
|
})
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue