diff --git a/sites/cosmote.gr/cosmote.gr.test.js b/sites/cosmote.gr/cosmote.gr.test.js
index 296c09a5..882d6b7a 100644
--- a/sites/cosmote.gr/cosmote.gr.test.js
+++ b/sites/cosmote.gr/cosmote.gr.test.js
@@ -1,6 +1,8 @@
-// npx epg-grabber --config=sites/cosmote.gr/cosmote.gr.config.js --channels=sites/cosmote.gr/cosmote.gr.channels.xml --output=guide.xml --days=2
+// npx epg-grabber --config=sites/cosmote.gr/cosmote.gr.config.js --channels=sites/cosmote.gr/cosmote.gr.channels.xml --output=guide.xml
const { parser, url } = require('./cosmote.gr.config.js')
+const fs = require('fs')
+const path = require('path')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
@@ -10,52 +12,67 @@ dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(customParseFormat)
-const date = dayjs.utc('2021-11-25', 'YYYY-MM-DD').startOf('d')
+const date = dayjs.utc('2023-06-08', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '4e',
xmltv_id: '4E.gr'
}
-const content = `
`
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
- 'https://www.cosmote.gr/cosmotetv/residential/program/epg/programchannel?p_p_id=channelprogram_WAR_OTETVportlet&p_p_lifecycle=0&_channelprogram_WAR_OTETVportlet_platform=IPTV&_channelprogram_WAR_OTETVportlet_date=25-11-2021&_channelprogram_WAR_OTETVportlet_articleTitleUrl=4e'
+ 'https://www.cosmotetv.gr/portal/residential/program/epg/programchannel?p_p_id=channelprogram_WAR_OTETVportlet&p_p_lifecycle=0&_channelprogram_WAR_OTETVportlet_platform=IPTV&_channelprogram_WAR_OTETVportlet_date=08-06-2023&_channelprogram_WAR_OTETVportlet_articleTitleUrl=4e'
)
})
it('can parse response', () => {
- const result = parser({ content, channel, date }).map(p => {
+ const content = fs.readFileSync(path.resolve(__dirname, '__data__/content1.html'))
+ const results = parser({ content, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
- expect(result).toMatchObject([
- {
- start: '2021-11-24T23:15:00.000Z',
- stop: '2021-11-24T23:50:00.000Z',
- title: `Μαθαίνω να Είμαι Γονιός`,
- category: 'Ντοκιμαντέρ'
- },
- {
- start: '2021-11-25T21:00:00.000Z',
- stop: '2021-11-25T21:45:00.000Z',
- title: `Μικρό Απόδειπνο`,
- category: 'Special'
- },
- {
- start: '2021-11-25T21:45:00.000Z',
- stop: '2021-11-26T01:00:00.000Z',
- title: `Πανηγυρική Αρχιερατική Θεία Λειτουργία`,
- category: 'Special'
- }
- ])
+ expect(results[0]).toMatchObject({
+ start: '2023-06-07T20:30:00.000Z',
+ stop: '2023-06-07T21:45:00.000Z',
+ title: `Τηλεφημερίδα`,
+ category: 'Εκπομπή - Μαγκαζίνο'
+ })
+
+ expect(results[30]).toMatchObject({
+ start: '2023-06-08T19:45:00.000Z',
+ stop: '2023-06-08T20:30:00.000Z',
+ title: `Μικρό Απόδειπνο`,
+ category: 'Special'
+ })
+})
+
+it('can parse response when the guide starting before midnight', () => {
+ const content = fs.readFileSync(path.resolve(__dirname, '__data__/content2.html'))
+ const results = parser({ content, date }).map(p => {
+ p.start = p.start.toJSON()
+ p.stop = p.stop.toJSON()
+ return p
+ })
+
+ expect(results[0]).toMatchObject({
+ start: '2023-06-07T21:30:00.000Z',
+ stop: '2023-06-07T22:30:00.000Z',
+ title: `Καλύτερα Αργά`,
+ category: 'Ψυχαγωγική Εκπομπή'
+ })
+
+ expect(results[22]).toMatchObject({
+ start: '2023-06-08T19:00:00.000Z',
+ stop: '2023-06-08T21:30:00.000Z',
+ title: `Πίσω Από Τις Γραμμές`,
+ category: 'Εκπομπή - Μαγκαζίνο'
+ })
})
it('can handle empty guide', () => {
const result = parser({
date,
- channel,
content: ``
})
expect(result).toMatchObject([])