Update cosmote.gr.test.js
This commit is contained in:
1 parent
dbe5bf7eb2
commit
2a9be054d5
1 file changed
+43
-26
@@ -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 = `<!DOCTYPE html><html class="aui ltr" dir="ltr" lang="el-GR"> <head></head> <body> <div id="page-wrap"> <section id="main-content" class="container-fluid homepage-layout" role="main"> <div class="row-fluid no-space"> <div class="portlet-column portlet-column-only col-xs-12" id="column-5"> <div class="portlet-dropzone portlet-column-content portlet-column-content-only" id="layout-column_column-5" > <div class=" portlet-boundary portlet-boundary_channelprogram_WAR_OTETVportlet_ portlet-static portlet-static-end channel-program-portlet " id="p_p_id_channelprogram_WAR_OTETVportlet_" > <section class="portlet" id="portlet_channelprogram_WAR_OTETVportlet"> <div class="portlet-content"> <div class="portlet-content-container"> <div class="portlet-body"> <section class="channel_program"> <div class="tabbable"> <div class="tab-content limiter"> <div class="tab-pane fade active in" id="broadband"> <div class="row"> <div class="col-sm-2"> <img class="channel_program-banner" alt="4Ε" title="4Ε" src="/portal/image/journal/article?img_id=56014332&t=1544180299920"/> </div><div class="col-sm-10"> <table class="channel_program-table table"> <tbody id="_channelprogram_WAR_OTETVportlet_programs"> <tr class="hidden-xs"> <td class="channel_program-table--program"> <a href="https://www.cosmote.gr/cosmotetv/residential/program/epg/closeupepg?p_p_id=epgcloseup_WAR_OTETVportlet&p_p_lifecycle=0&p_p_col_id=column-5&p_p_col_count=1&_epgcloseup_WAR_OTETVportlet_articleId=119045589&_epgcloseup_WAR_OTETVportlet_redirect=https%253A%252F%252Fwww.cosmote.gr%252Fportal%252Fresidential%252Fprogram%252Fepg%252Fprogramchannel" >Μαθαίνω να Είμαι Γονιός</a > </td><td class=" channel_program-table--time channel_program-table--program_type " > <span class="start-time">01:15</span> - <span class="end-time">01:50</span> (<span class="duration" >35'</span >) | Ντοκιμαντέρ </td></tr><tr class="visible-xs"> <td class=" channel_program-table--program channel_program-table--time channel_program-table--program_type " colspan="2" > <span class="start-time">01:15</span> - <span class="end-time">01:50</span> (<span class="duration" >35'</span >) | Ντοκιμαντέρ<br/> <a href="https://www.cosmote.gr/cosmotetv/residential/program/epg/closeupepg?p_p_id=epgcloseup_WAR_OTETVportlet&p_p_lifecycle=0&p_p_col_id=column-5&p_p_col_count=1&_epgcloseup_WAR_OTETVportlet_articleId=119045589&_epgcloseup_WAR_OTETVportlet_redirect=https%253A%252F%252Fwww.cosmote.gr%252Fportal%252Fresidential%252Fprogram%252Fepg%252Fprogramchannel" >Μαθαίνω να Είμαι Γονιός</a > </td></tr><tr class="hidden"></tr><tr class="hidden-xs"> <td class="channel_program-table--program"> <a href="https://www.cosmote.gr/cosmotetv/residential/program/epg/closeupepg?p_p_id=epgcloseup_WAR_OTETVportlet&p_p_lifecycle=0&p_p_col_id=column-5&p_p_col_count=1&_epgcloseup_WAR_OTETVportlet_articleId=119045942&_epgcloseup_WAR_OTETVportlet_redirect=https%253A%252F%252Fwww.cosmote.gr%252Fportal%252Fresidential%252Fprogram%252Fepg%252Fprogramchannel" >Μικρό Απόδειπνο</a > </td><td class=" channel_program-table--time channel_program-table--program_type " > <span class="start-time">23:00</span> - <span class="end-time">23:45</span> (<span class="duration" >45'</span >) | Special </td></tr><tr class="visible-xs"> <td class=" channel_program-table--program channel_program-table--time channel_program-table--program_type " colspan="2" > <span class="start-time">23:00</span> - <span class="end-time">23:45</span> (<span class="duration" >45'</span >) | Special<br/> <a href="https://www.cosmote.gr/cosmotetv/residential/program/epg/closeupepg?p_p_id=epgcloseup_WAR_OTETVportlet&p_p_lifecycle=0&p_p_col_id=column-5&p_p_col_count=1&_epgcloseup_WAR_OTETVportlet_articleId=119045942&_epgcloseup_WAR_OTETVportlet_redirect=https%253A%252F%252Fwww.cosmote.gr%252Fportal%252Fresidential%252Fprogram%252Fepg%252Fprogramchannel" >Μικρό Απόδειπνο</a > </td></tr><tr class="hidden"></tr><tr class="hidden-xs"> <td class="channel_program-table--program"> <a href="https://www.cosmote.gr/cosmotetv/residential/program/epg/closeupepg?p_p_id=epgcloseup_WAR_OTETVportlet&p_p_lifecycle=0&p_p_col_id=column-5&p_p_col_count=1&_epgcloseup_WAR_OTETVportlet_articleId=119045955&_epgcloseup_WAR_OTETVportlet_redirect=https%253A%252F%252Fwww.cosmote.gr%252Fportal%252Fresidential%252Fprogram%252Fepg%252Fprogramchannel" >Πανηγυρική Αρχιερατική Θεία Λειτουργία</a > </td><td class=" channel_program-table--time channel_program-table--program_type " > <span class="start-time">23:45</span> - <span class="end-time">03:00</span> (<span class="duration" >195'</span >) | Special </td></tr><tr class="visible-xs"> <td class=" channel_program-table--program channel_program-table--time channel_program-table--program_type " colspan="2" > <span class="start-time">23:45</span> - <span class="end-time">03:00</span> (<span
Line truncated
|
||||
|
||||
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: `<!DOCTYPE html><html><head></head><body></body></html>`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
|
||||
Reference in new issue
Block a user