From 14c4ca3916bea3dae254851a3f7d93918e242fc5 Mon Sep 17 00:00:00 2001 From: fraudiay79 <60631277+fraudiay79@users.noreply.github.com> Date: Thu, 26 Dec 2024 14:56:29 -0500 Subject: [PATCH] Create ipko.tv.test.js --- sites/ipko.tv/ipko.tv.test.js | 115 ++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 sites/ipko.tv/ipko.tv.test.js diff --git a/sites/ipko.tv/ipko.tv.test.js b/sites/ipko.tv/ipko.tv.test.js new file mode 100644 index 00000000..2064eeb0 --- /dev/null +++ b/sites/ipko.tv/ipko.tv.test.js @@ -0,0 +1,115 @@ +const { parser, url } = require('./ipko.tv.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('2024-12-24', 'YYYY-MM-DD').startOf('day') +const channel = { + site_id: 'ipko-promo', + xmltv_id: 'IPKOPROMO' +} + +it('can generate valid url', () => { + expect(url({ date, channel })).toBe('https://stargate.ipko.tv/api/titan.tv.WebEpg/GetWebEpgData') +}) + +it('can parse response', () => { + const content = ` + { + "shows": [ + { + "title": "IPKO Promo", + "show_start": 1735012800, + "show_end": 1735020000, + "timestamp": "5:00 - 7:00", + "show_id": "EPG_TvProfil_IPKOPROMO_296105567", + "thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg", + "is_adult": false, + "friendly_id": "ipko_promo_4cf3", + "pg": "", + "genres": [], + "year": 0, + "summary": "", + "categories": "Other", + "stb_only": false, + "is_live": false, + "original_title": "IPKO Promo" + }, + { + "title": "IPKO Promo", + "show_start": 1735020000, + "show_end": 1735027200, + "timestamp": "7:00 - 9:00", + "show_id": "EPG_TvProfil_IPKOPROMO_296105568", + "thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg", + "is_adult": false, + "friendly_id": "ipko_promo_416b", + "pg": "", + "genres": [], + "year": 0, + "summary": "", + "categories": "Other", + "stb_only": false, + "is_live": false, + "original_title": "IPKO Promo" + }, + { + "title": "IPKO Promo", + "show_start": 1735027200, + "show_end": 1735034400, + "timestamp": "9:00 - 11:00", + "show_id": "EPG_TvProfil_IPKOPROMO_296105569", + "thumbnail": "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg", + "is_adult": false, + "friendly_id": "ipko_promo_2e23", + "pg": "", + "genres": [], + "year": 0, + "summary": "", + "categories": "Other", + "stb_only": false, + "is_live": false, + "original_title": "IPKO Promo" + } + ] + }` + + const result = parser({ content, channel }).map(p => { + p.start = p.start + p.stop = p.stop + return p + }) + + expect(result).toMatchObject([ + { + title: "IPKO Promo", + description: "No description available", + start: "2024-12-24T04:00:00.000Z", + stop: "2024-12-24T06:00:00.000Z", + thumbnail: "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg" + }, + { + title: "IPKO Promo", + description: "No description available", + start: "2024-12-24T06:00:00.000Z", + stop: "2024-12-24T08:00:00.000Z", + thumbnail: "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg" + }, + { + title: "IPKO Promo", + description: "No description available", + start: "2024-12-24T08:00:00.000Z", + stop: "2024-12-24T10:00:00.000Z", + thumbnail: "https://vimg.ipko.tv/mtcms/18/2/1/1821cc68-a9bf-4733-b1af-9a5d80163b78.jpg" + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + content: '{"shows":[]}' + }) + expect(result).toMatchObject([]) +})