diff --git a/sites/mncvision.id/mncvision.id.test.js b/sites/mncvision.id/mncvision.id.test.js index 6055d9d1..e7a40388 100644 --- a/sites/mncvision.id/mncvision.id.test.js +++ b/sites/mncvision.id/mncvision.id.test.js @@ -1,5 +1,5 @@ // 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 +// npx epg-grabber --config=sites/mncvision.id/mncvision.id.config.js --channels=sites/mncvision.id/mncvision.id_id.channels.xml --output=guide.xml --days=2 const { parser, url, request } = require('./mncvision.id.config.js') const axios = require('axios') @@ -16,7 +16,11 @@ const channel = { site_id: '203', xmltv_id: 'AnimalPlanetSoutheastAsia.us' } -const content = `
Jam Tayang Program Acara Durasi
00:00African Wild S1: Seals01:00
` +const setCookie = [ + 's1nd0vL=0qpsmm7dpjmi7nt8d2h5epf16rmgg8a8; expires=Sat, 05-Mar-2022 15:44:22 GMT; Max-Age=7200; path=/; HttpOnly' +] +const content0 = `

Jadwal Tayang Cari

Jadwal Tayang Channel: 41 Tanggal: 2022-03-05
Jam Tayang Program Acara Durasi
00:00Hey Duggee S3, Ep 2200:07
page: 12
` +const content50 = `

Jadwal Tayang Cari

Jadwal Tayang Channel: 41 Tanggal: 2022-03-05
Jam Tayang Program Acara Durasi
08:25Hey Duggee S1, Ep 4600:07
page: 12
` it('can generate valid url', () => { expect(url).toBe('https://mncvision.id/schedule/table') @@ -34,45 +38,45 @@ it('can generate valid request data', () => { }) it('can parse response', done => { - axios.get.mockImplementation(() => - Promise.resolve({ - data: `
+ axios.get.mockImplementation((url, options = {}) => { + if (url === 'https://www.mncvision.id/schedule/detail/2022030500000041/Hey-Duggee-S3-Ep-22/1') { + return Promise.resolve({ + data: `
Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan.
` - }) - ) + }) + } else if ( + url === 'https://www.mncvision.id/schedule/table/startno/50' && + options.headers && + options.headers['Cookie'] === setCookie.join(';') + ) { + return Promise.resolve({ + data: content50 + }) + } - parser({ date, channel, content }) + return Promise.resolve({ data: '' }) + }) + + parser({ date, content: content0, headers: { 'set-cookie': setCookie } }) .then(result => { + result = result.map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + expect(result).toMatchObject([ { start: '2021-11-11T17:00:00.000Z', - stop: '2021-11-11T18:00:00.000Z', - title: 'African Wild S1: Seals', + stop: '2021-11-11T17:07:00.000Z', + title: 'Hey Duggee S3, Ep 22', 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', + start: '2021-11-12T01:25:00.000Z', + stop: '2021-11-12T01:32:00.000Z', + title: 'Hey Duggee S1, Ep 46', description: null } ])