// node ./scripts/channels.js --config=./sites/mncvision.id/mncvision.id.config.js --output=./sites/mncvision.id/mncvision.id_id.channels.xml // npx epg-grabber --config=sites/mncvision.id/mncvision.id.config.js --channels=sites/mncvision.id/mncvision.id_id.channels.xml --output=.gh-pages/guides/id/mncvision.id.epg.xml --days=2 const { parser, url, request, logo } = require('./mncvision.id.config.js') const axios = require('axios') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(customParseFormat) dayjs.extend(utc) jest.mock('axios') const date = dayjs.utc('2021-11-12', 'YYYY-MM-DD').startOf('d') const channel = { site_id: '203', xmltv_id: 'AnimalPlanetSoutheastAsia.us' } const content = `
Jam Tayang | Program Acara | Durasi |
---|---|---|
00:00 | African Wild S1: Seals | 01:00 |
Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan.` }) ) parser({ date, channel, content }) .then(result => { expect(result).toMatchObject([ { start: '2021-11-11T17:00:00.000Z', stop: '2021-11-11T18:00:00.000Z', title: 'African Wild S1: Seals', description: 'Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan.' } ]) done() }) .catch(error => { done(error) }) }) it('can parse response with empty description', done => { axios.get.mockImplementation(() => Promise.resolve({ data: `
-` }) ) parser({ date, channel, content }) .then(result => { expect(result).toMatchObject([ { start: '2021-11-11T17:00:00.000Z', stop: '2021-11-11T18:00:00.000Z', title: 'African Wild S1: Seals', description: null } ]) done() }) .catch(error => { done(error) }) }) it('can handle empty guide', done => { parser({ date, channel, content: `` }) .then(result => { expect(result).toMatchObject([]) done() }) .catch(error => { done(error) }) })