diff --git a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js new file mode 100644 index 00000000..3c8485ea --- /dev/null +++ b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js @@ -0,0 +1,59 @@ +// npx epg-grabber --config=sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js --channels=sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr_hr.channels.xml --output=.gh-pages/guides/hr/maxtv.hrvatskitelekom.hr.epg.xml --days=2 + +const { parser, url, request, logo } = require('./maxtv.hrvatskitelekom.hr.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-11-16', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '316', + xmltv_id: '24KitchenHrvatska.us' +} +const content = `{"status":{"code":200,"message":"OK","authType":"Unauthenticated","ottSessionToken":null},"data":[{"channelId":"316","title":"24Kitchen","logo":"http://ottepg5.nexttv.ht.hr:33200/EPG/jsp/images/universal/film/logo/fileEntity/20161109/000200/XTV100002173/493d03f8-0f08-4932-8371-e5b57d96f17d.png","chanNumber":500,"hasCatchup":false,"ottChannel":true,"userSubscribed":false,"shows":[{"showId":"17298142","title":"NajĨudniji svjetski restorani","startTime":1636952400,"endTime":1636952700,"category":"Kulinarski","hasReminder":false,"hasRecording":false,"hasSeriesRecording":false,"userOttPlayable":false,"userLocked":false,"isPPV":false,"buyPrice":""}]}]}` + +it('can generate valid url', () => { + expect(url).toBe('https://player.maxtvtogo.tportal.hr:8082/OTT4Proxy/proxy/epg/shows') +}) + +it('can generate valid request data', () => { + expect(request.data({ channel, date })).toMatchObject({ + channelList: ['316'], + startDate: 1637020800, + endDate: 1637107200 + }) +}) + +it('can get logo url', () => { + expect(logo({ channel, content })).toBe( + 'http://ottepg5.nexttv.ht.hr:33200/EPG/jsp/images/universal/film/logo/fileEntity/20161109/000200/XTV100002173/493d03f8-0f08-4932-8371-e5b57d96f17d.png' + ) +}) + +it('can parse response', () => { + const result = parser({ channel, content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2021-11-15T05:00:00.000Z', + stop: '2021-11-15T05:05:00.000Z', + title: 'NajĨudniji svjetski restorani', + category: 'Kulinarski' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `{"status":{"code":200,"message":"OK","authType":"Unauthenticated","ottSessionToken":null},"data":[]}` + }) + expect(result).toMatchObject([]) +})