From b21527134f9b82d9755fe0d9f95cc64ce6b9171c Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 8 May 2022 16:26:36 +0300 Subject: [PATCH] Update beinsports.com.test.js --- sites/beinsports.com/beinsports.com.test.js | 96 ++++++--------------- 1 file changed, 28 insertions(+), 68 deletions(-) diff --git a/sites/beinsports.com/beinsports.com.test.js b/sites/beinsports.com/beinsports.com.test.js index 50daaa9c..487eb08a 100644 --- a/sites/beinsports.com/beinsports.com.test.js +++ b/sites/beinsports.com/beinsports.com.test.js @@ -1,86 +1,46 @@ // npx epg-grabber --config=sites/beinsports.com/beinsports.com.config.js --channels=sites/beinsports.com/beinsports.com_qa.channels.xml --output=guide.xml --timeout=30000 --days=2 const { parser, url } = require('./beinsports.com.config.js') +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('2021-10-24', 'YYYY-MM-DD').startOf('d') -const channel = { site_id: '1', xmltv_id: 'BeInSports.qa' } -const content = ` -
-
-
-
-
-
-
-
-
-
    -
    -
    -
    -
    -
    Live Events
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    • -
      -

      Red Bull Car Park Drift 2021

      -

      MotorSports

      -
      -

      21:45 - 00:40

      -
      70% Complete
    • - -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -` +const date = dayjs.utc('2022-05-08', 'YYYY-MM-DD').startOf('d') +const channel = { site_id: '#1', xmltv_id: 'BeINSports.qa' } it('can generate valid url', () => { const result = url({ date }) expect(result).toBe( - 'https://epg.beinsports.com/utctime.php?mins=00&serviceidentity=beinsports.com&cdate=2021-10-24' + 'https://epg.beinsports.com/utctime.php?mins=00&serviceidentity=beinsports.com&cdate=2022-05-08' ) }) it('can parse response', () => { - const result = parser({ date, channel, content }) - expect(result).toMatchObject([ - { - start: 'Sat, 23 Oct 2021 21:45:00 GMT', - stop: 'Sun, 24 Oct 2021 00:40:00 GMT', - title: 'Red Bull Car Park Drift 2021', - category: 'MotorSports' - } - ]) + const content = fs.readFileSync(path.resolve('sites/beinsports.com/__data__/content.html')) + const results = parser({ date, channel, content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(results[0]).toMatchObject({ + start: '2022-05-07T19:45:00.000Z', + stop: '2022-05-07T21:30:00.000Z', + title: 'Al Arabi vs Al Khor - Qatar Stars League 2021/2022', + category: 'Qatar Stars League' + }) +}) + +it('can handle empty guide', () => { + const noContent = fs.readFileSync(path.resolve('sites/beinsports.com/__data__/no-content.html')) + const result = parser({ + date, + channel, + content: noContent + }) + expect(result).toMatchObject([]) })