// npx epg-grabber --config=sites/m.tv.sms.cz/m.tv.sms.cz.config.js --channels=sites/m.tv.sms.cz/m.tv.sms.cz_cz.channels.xml --output=.gh-pages/guides/cz/m.tv.sms.cz.epg.xml --days=2 const { parser, url } = require('./m.tv.sms.cz.config.js') const iconv = require('iconv-lite') 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-24', 'YYYY-MM-DD').startOf('d') const channel = { site_id: 'Cero', xmltv_id: '0.es' } const content = `
` const buffer = iconv.encode(Buffer.from(content), 'win1250') it('can generate valid url', () => { expect(url({ channel, date })).toBe( 'https://m.tv.sms.cz/index.php?stanice=Cero&cas=0&den=2021-11-24' ) }) it('can parse response', () => { const result = parser({ buffer, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) expect(result).toMatchObject([ { start: '2021-11-24T04:02:00.000Z', stop: '2021-11-24T04:56:00.000Z', title: `La magia de la Luna: El octavo continente`, description: 'Documentales' }, { start: '2021-11-24T04:56:00.000Z', stop: '2021-11-24T22:00:00.000Z', title: `Explorando Europa: El nacimiento de un continente`, description: 'Documentales' }, { start: '2021-11-24T22:00:00.000Z', stop: '2021-11-24T23:05:00.000Z', title: `Late Motiv (41)`, description: 'Entretenimiento' }, { start: '2021-11-24T23:05:00.000Z', stop: '2021-11-25T00:20:00.000Z', title: `La Resistencia (41)`, description: 'Entretenimiento' }, { start: '2021-11-25T00:20:00.000Z', stop: '2021-11-25T01:20:00.000Z', title: `Ilustres Ignorantes: Cantantes`, description: 'Entretenimiento' } ]) }) it('can handle empty guide', () => { const result = parser({ buffer: iconv.encode( Buffer.from( `` ), 'win1250' ) }) expect(result).toMatchObject([]) })