From 956f9b22a523b215f7a815ef51d8208ea0798329 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 28 Oct 2021 09:36:33 +0300 Subject: [PATCH] Update dstv.com.test.js --- sites/dstv.com/dstv.com.test.js | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/sites/dstv.com/dstv.com.test.js b/sites/dstv.com/dstv.com.test.js index 4cf2f1b8..f5523e3f 100644 --- a/sites/dstv.com/dstv.com.test.js +++ b/sites/dstv.com/dstv.com.test.js @@ -1 +1,67 @@ // npx epg-grabber --config=sites/dstv.com/dstv.com.config.js --channels=sites/dstv.com/dstv.com_ao.channels.xml --days=1 --output=.gh-pages/guides/ao/dstv.com.epg.xml + +const { parser, url, logo } = require('./dstv.com.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-10-24', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'b0dc42b8-c651-4c3c-8713-a7fcd04744ee#M4H', + xmltv_id: 'MNetMovies4.za', + logo: 'https://rndcdn.dstv.com/dstvcms/2020/09/01/M-Net_Movies_4_Logo_4-3_lightbackground_xlrg.png' +} +const content = JSON.stringify({ + M4H: "
  • 21:30

    Deadly Flight

  • 08:25

    I Still Believe

  • 15:50

    Despicable Me

  • 20:35

    The Foreigner

  • " +}) + +it('can generate valid url', () => { + const result = url({ date, channel }) + expect(result).toBe( + 'https://guide.dstv.com/api/gridview/page?bouquetId=b0dc42b8-c651-4c3c-8713-a7fcd04744ee&genre=all&date=2021-10-24' + ) +}) + +it('can get logo url', done => { + logo({ channel }) + .then(result => { + expect(result).toBe( + 'https://rndcdn.dstv.com/dstvcms/2020/09/01/M-Net_Movies_4_Logo_4-3_lightbackground_xlrg.png' + ) + done() + }) + .catch(error => done(error)) +}) + +fit('can parse response', () => { + const result = parser({ date, channel, content }) + expect(result).toMatchObject([ + { + start: 'Sat, 23 Oct 2021 21:30:00 GMT', + stop: 'Sun, 24 Oct 2021 08:25:00 GMT', + title: 'Deadly Flight' + }, + { + start: 'Sun, 24 Oct 2021 08:25:00 GMT', + stop: 'Sun, 24 Oct 2021 15:50:00 GMT', + title: 'I Still Believe' + }, + { + start: 'Sun, 24 Oct 2021 15:50:00 GMT', + stop: 'Sun, 24 Oct 2021 20:35:00 GMT', + title: 'Despicable Me' + }, + { + start: 'Sun, 24 Oct 2021 20:35:00 GMT', + stop: 'Sun, 24 Oct 2021 21:35:00 GMT', + title: 'The Foreigner' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ date, channel, content: `{}` }) + expect(result).toMatchObject([]) +})