mirror of
https://github.com/iptv-org/epg
synced 2026-05-06 17:37:06 -04:00
feat: nhl.com site
I was having trouble with the extant sites for this channel so I decided to add a source for the league's own guide. Unfortunately it's missing images since I don't know where they need to be hosted :(
This commit is contained in:
44
sites/nhl.com/nhl.com.test.js
Normal file
44
sites/nhl.com/nhl.com.test.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const { parser, url } = require('./nhl.com.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('2024-11-21', 'YYYY-MM-DD').startOf('d')
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ date })).toBe(
|
||||
'https://api-web.nhle.com/v1/network/tv-schedule/2024-11-21'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content, date })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2024-11-21T12:00:00.000Z',
|
||||
stop: '2024-11-21T13:00:00.000Z',
|
||||
title: 'On The Fly',
|
||||
category: 'Sports non-event',
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: JSON.stringify({
|
||||
// extra props not necessary but they form a valid response
|
||||
date: "2024-11-21",
|
||||
startDate: "2024-11-07",
|
||||
endDate: "2024-12-05",
|
||||
broadcasts: [],
|
||||
}) })
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
Reference in New Issue
Block a user