From 1c9ed540438ce7afaa16b0d075c78ea8fe51e22c Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 24 Nov 2021 20:50:04 +0300 Subject: [PATCH] Create m.tv.sms.cz.test.js --- sites/m.tv.sms.cz/m.tv.sms.cz.test.js | 80 +++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 sites/m.tv.sms.cz/m.tv.sms.cz.test.js diff --git a/sites/m.tv.sms.cz/m.tv.sms.cz.test.js b/sites/m.tv.sms.cz/m.tv.sms.cz.test.js new file mode 100644 index 00000000..ea421258 --- /dev/null +++ b/sites/m.tv.sms.cz/m.tv.sms.cz.test.js @@ -0,0 +1,80 @@ +// 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, logo } = 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 generate valid logo url', () => { + expect(logo({ content })).toBe('https://www.sms.cz/kategorie/televize/bmp/loga/velka/cero.png') +}) + +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([]) +})