diff --git a/sites/tv.trueid.net/tv.trueid.net.test.js b/sites/tv.trueid.net/tv.trueid.net.test.js new file mode 100644 index 00000000..b99a270f --- /dev/null +++ b/sites/tv.trueid.net/tv.trueid.net.test.js @@ -0,0 +1,45 @@ +// npx epg-grabber --config=sites/tv.trueid.net/tv.trueid.net.config.js --channels=sites/tv.trueid.net/tv.trueid.net_th.channels.xml --days=1 --output=guide.xml + +const { parser, url, logo } = require('./tv.trueid.net.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('2021-10-28', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'tv-nfl-nba', + xmltv_id: 'NFLNBATV.us', + name: 'NFL & NBA TV' +} +const content = `` + +it('can generate valid url', () => { + const result = url({ channel, date }) + expect(result).toBe('https://tv.trueid.net/tvguide/all/tv-nfl-nba/2021-10-28') +}) + +it('can get logo url', () => { + const result = logo({ content, channel }) + expect(result).toBe( + 'https://cms.dmpcdn.com/livetv/2021/09/28/2c9c41c0-203b-11ec-9346-6f50de6452df_webp_original.png' + ) +}) + +it('can parse response', () => { + const result = parser({ date, channel, content }) + expect(result).toMatchObject([ + { + start: dayjs.utc('Thu, 28 Oct 2021 19:00:00 GMT'), + stop: dayjs.utc('Thu, 28 Oct 2021 21:00:00 GMT'), + title: 'NBA 2021/22', + icon: 'https://epgthumb.dmpcdn.com/thumbnail_large/t513/20211029/20211029_020000.jpg' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ date, channel, content: `{}` }) + expect(result).toMatchObject([]) +})