From 9611ee9327f8a1043d7df144903f9bc00a8331d2 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 10 Apr 2022 01:43:15 +0300 Subject: [PATCH] Create startimestv.com.test.js --- sites/startimestv.com/startimestv.com.test.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 sites/startimestv.com/startimestv.com.test.js diff --git a/sites/startimestv.com/startimestv.com.test.js b/sites/startimestv.com/startimestv.com.test.js new file mode 100644 index 00000000..f76cfd4f --- /dev/null +++ b/sites/startimestv.com/startimestv.com.test.js @@ -0,0 +1,48 @@ +// npm run channels:parse -- --config=./sites/startimestv.com/startimestv.com.config.js --output=./sites/startimestv.com/startimestv.com_ke.channels.xml --set=country:ke +// npx epg-grabber --config=sites/startimestv.com/startimestv.com.config.js --channels=sites/startimestv.com/startimestv.com_ke.channels.xml --output=guide.xml --days=2 + +const { parser, url } = require('./startimestv.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('2022-04-10', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '1023102509', + xmltv_id: 'ZeeOne.za' +} + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe( + 'https://www.startimestv.com/channeldetail/1023102509/2022-04-10.html' + ) +}) + +it('can parse response', () => { + const content = `

Guddan S2 E77

00:00-01:00

Vickrant is overjoyed to see Akshat in pain and not knowing what to do.

00:00-01:00 Guddan S2 E77

Vickrant is overjoyed to see Akshat in pain and not knowing what to do.

` + const result = parser({ content, date }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2022-04-10T00:00:00.000Z', + stop: '2022-04-10T01:00:00.000Z', + title: 'Guddan S2 E77', + season: 2, + episode: 77, + description: 'Vickrant is overjoyed to see Akshat in pain and not knowing what to do.' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + content: `

Rate:

Category:


` + }) + expect(result).toMatchObject([]) +})