// npm run grab -- --site=hd-plus.de const { parser, url } = 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', () => { const today = dayjs.utc().startOf('d') expect(url({ channel, date: today })).toBe('https://www.hd-plus.de/epg/channel/1-2-3-tv-hd?d=0') }) 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([]) })