diff --git a/sites/programetv.ro/programetv.ro.test.js b/sites/programetv.ro/programetv.ro.test.js new file mode 100644 index 00000000..1a1cd16a --- /dev/null +++ b/sites/programetv.ro/programetv.ro.test.js @@ -0,0 +1,74 @@ +// npx epg-grabber --config=sites/programetv.ro/programetv.ro.config.js --channels=sites/programetv.ro/programetv.ro_ro.channels.xml --output=.gh-pages/guides/ro/programetv.ro.epg.xml --days=2 + +const { parser, url, logo } = require('./programetv.ro.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: 'pro-tv', xmltv_id: 'ProTV.ro' } +const content = ` + + +
+ + +` + +it('can generate valid url', () => { + const result = url({ date, channel }) + expect(result).toBe('https://www.programetv.ro/post/pro-tv/duminica/') +}) + +it('can get logo url', () => { + const result = logo({ content }) + expect(result).toBe('https://static.cinemagia.ro/img/tv_station/pro-tv.jpg') +}) + +it('can parse response', () => { + const result = parser({ date, channel, content }) + expect(result).toMatchObject([ + { + start: 'Sun, 07 Nov 2021 05:00:00 GMT', + stop: 'Sun, 07 Nov 2021 07:59:59 GMT', + title: 'Ştirile Pro Tv', + description: `În fiecare zi, cele mai importante evenimente, transmisiuni LIVE, analize, anchete şi reportaje sunt la Ştirile ProTV.`, + category: ['Ştiri'], + icon: 'https://www.programetv.ro/img/shows/84/54/stirile-pro-tv.png?key=Z2lfZnVial90cmFyZXZwLzAwLzAwLzA1LzE4MzgxMnktMTIwazE3MC1hLW40NTk4MW9zLmNhdA==' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: ` + + + + + + +` + }) + expect(result).toMatchObject([]) +})