diff --git a/sites/hd-plus.de/hd-plus.de.test.js b/sites/hd-plus.de/hd-plus.de.test.js new file mode 100644 index 00000000..5cb6218a --- /dev/null +++ b/sites/hd-plus.de/hd-plus.de.test.js @@ -0,0 +1,58 @@ +// npx epg-grabber --config=sites/hd-plus.de/hd-plus.de.config.js --channels=sites/hd-plus.de/hd-plus.de_de.channels.xml --output=.gh-pages/guides/de/hd-plus.de.epg.xml --days=2 + +const { parser, url, logo } = require('./hd-plus.de.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-11-25', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '1-2-3-tv-hd', + xmltv_id: '123TV.de' +} +const content = `
1-2-3.tv HD

1-2-3.tv HD

Titel Ausstrahlungszeit
Ihre Lieblingsuhren Do 25.11 00:00
Ihre Lieblingsuhren Do 25.11 01:00
Flash DealsDo 25.11 06:00
` + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe('https://www.hd-plus.de/epg/channel/1-2-3-tv-hd?d=0') +}) + +it('can generate valid logo url', () => { + expect(logo({ content })).toBe('https://cdn.hd-plus.de/senderlogos/bright-cropped/24444-2.png') +}) + +it('can parse response', () => { + const result = parser({ content, channel, date }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2021-11-24T23:00:00.000Z', + stop: '2021-11-25T00:00:00.000Z', + title: `Ihre Lieblingsuhren` + }, + { + start: '2021-11-25T00:00:00.000Z', + stop: '2021-11-25T05:00:00.000Z', + title: `Ihre Lieblingsuhren` + }, + { + start: '2021-11-25T05:00:00.000Z', + stop: '2021-11-25T06:00:00.000Z', + title: `Flash Deals` + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `` + }) + expect(result).toMatchObject([]) +})