From 7855c565b0812fe630d4e634cfa65b52cedb872e Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 6 Nov 2021 11:31:55 +0300 Subject: [PATCH] Create vivacom.bg.test.js --- sites/vivacom.bg/vivacom.bg.test.js | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sites/vivacom.bg/vivacom.bg.test.js diff --git a/sites/vivacom.bg/vivacom.bg.test.js b/sites/vivacom.bg/vivacom.bg.test.js new file mode 100644 index 00000000..da29192a --- /dev/null +++ b/sites/vivacom.bg/vivacom.bg.test.js @@ -0,0 +1,49 @@ +// npx epg-grabber --config=sites/vivacom.bg/vivacom.bg.config.js --channels=sites/vivacom.bg/vivacom.bg_bg.channels.xml --output=.gh-pages/guides/bg/vivacom.bg.epg.xml --days=2 + +const { parser, url, logo, request } = require('./vivacom.bg.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-05', 'YYYY-MM-DD').startOf('d') +const channel = { site_id: '1#БНТ 1 HD', xmltv_id: 'BNT1.bg' } +const content = `
  • Когато сърцето зове

    04:25:00 - 05:10:00

    Телевизионен филм. Тв филм /4 сезон, 5 епизод/п/

  • Dreamy Nights: Songs & Rhymes

    23:30:00 - 00:00:00

    Songs & Rhymes, Flowers, Milky Way, Close Your Eyes, Twilight

` + +it('can generate valid url', () => { + const result = url({ date, channel }) + expect(result).toBe('https://www.vivacom.bg/bg/tv/programa/?date=2021-11-05&page=1') +}) + +it('can get logo url', () => { + const result = logo({ content, channel }) + expect(result).toBe('https://www.vivacom.bg/web/files/richeditor/tv/bnt-1-hd.png') +}) + +it('can parse response', () => { + const result = parser({ date, channel, content }) + expect(result).toMatchObject([ + { + start: '2021-11-05T02:25:00.000Z', + stop: '2021-11-05T03:10:00.000Z', + title: 'Когато сърцето зове', + description: 'Телевизионен филм. Тв филм /4 сезон, 5 епизод/п/' + }, + { + start: '2021-11-05T21:30:00.000Z', + stop: '2021-11-05T22:00:00.000Z', + title: 'Dreamy Nights: Songs & Rhymes', + description: 'Songs & Rhymes, Flowers, Milky Way, Close Your Eyes, Twilight' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `
` + }) + expect(result).toMatchObject([]) +})