From c52e3446becc9f9186106a1732dde93e2f6ffbb6 Mon Sep 17 00:00:00 2001 From: freearhey Date: Sun, 11 Jun 2023 22:53:17 +0300 Subject: [PATCH] Update m.tv.sms.cz.test.js --- sites/m.tv.sms.cz/m.tv.sms.cz.test.js | 60 +++++++++------------------ 1 file changed, 20 insertions(+), 40 deletions(-) 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 index 4f98ecc6..49426b41 100644 --- a/sites/m.tv.sms.cz/m.tv.sms.cz.test.js +++ b/sites/m.tv.sms.cz/m.tv.sms.cz.test.js @@ -1,14 +1,16 @@ -// 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.channels.xml --output=guide.xml --days=2 +// 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.channels.xml --output=guide.xml const { parser, url } = require('./m.tv.sms.cz.config.js') const iconv = require('iconv-lite') +const fs = require('fs') +const path = require('path') 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('2022-03-30', 'YYYY-MM-DD').startOf('d') +const date = dayjs.utc('2023-06-11', 'YYYY-MM-DD').startOf('d') const channel = { site_id: 'Cero', xmltv_id: '0.es' @@ -16,54 +18,32 @@ const channel = { it('can generate valid url', () => { expect(url({ channel, date })).toBe( - 'https://m.tv.sms.cz/index.php?stanice=Cero&cas=0&den=2022-03-30' + 'https://m.tv.sms.cz/index.php?stanice=Cero&cas=0&den=2023-06-11' ) }) it('can parse response', () => { - let content = `
` + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) const buffer = iconv.encode(content, 'win1250') - const result = parser({ content, buffer, date }).map(p => { + const results = parser({ buffer, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) - expect(result).toMatchObject([ - { - start: '2022-03-30T03:25:00.000Z', - stop: '2022-03-30T04:00:00.000Z', - title: `Před kamerou XIX (8)`, - description: 'Filmový magazín Francie / USA (2022)' - }, - { - start: '2022-03-30T04:00:00.000Z', - stop: '2022-03-30T20:35:00.000Z', - title: `Kubánská spojka`, - description: - 'Na přelomu 80. a 90. let minulého století podnikaly povstalecké skupiny sídlící na Floridě násilné ú...' - }, - { - start: '2022-03-30T20:35:00.000Z', - stop: '2022-03-30T23:15:00.000Z', - title: `Patriot`, - description: - 'Jižní Karolína, 1776. Benjamin Martin, hrdina, který bojoval proti Francouzům a Indiánům, žije v kli...' - }, - { - start: '2022-03-30T23:15:00.000Z', - stop: '2022-03-31T00:25:00.000Z', - title: `Chelsea Handler: Evoluce`, - description: - 'Chelsea Handlerová se po šestileté přestávce vrací ke stand-up comedy ve speciálu HBO Max. Během hod...' - }, - { - start: '2022-03-31T00:25:00.000Z', - stop: '2022-03-31T01:25:00.000Z', - title: `Drápy IV (8)`, - description: 'Kriminální komediální drama USA (2020)' - } - ]) + expect(results[0]).toMatchObject({ + start: '2023-06-11T03:21:00.000Z', + stop: '2023-06-11T04:08:00.000Z', + title: `Conspiraciones al descubierto: La bomba atómica alemana y el hundimiento del Titanic`, + description: 'Documentales' + }) + + expect(results[25]).toMatchObject({ + start: '2023-06-12T02:23:00.000Z', + stop: '2023-06-12T03:23:00.000Z', + title: `Rapa I (6)`, + description: 'Series' + }) }) it('can handle empty guide', () => {