mirror of
https://github.com/iptv-org/epg
synced 2026-09-15 13:36:25 -04:00
Update movistarplus.es.test.js
This commit is contained in:
@@ -6,8 +6,10 @@ const utc = require('dayjs/plugin/utc')
|
|||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
const axios = require('axios')
|
||||||
|
jest.mock('axios')
|
||||||
|
|
||||||
const date = dayjs.utc('2025-01-23', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2025-05-30', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: 'sexta',
|
site_id: 'sexta',
|
||||||
xmltv_id: 'LaSexta.es'
|
xmltv_id: 'LaSexta.es'
|
||||||
@@ -15,36 +17,64 @@ const channel = {
|
|||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url({ channel, date })).toBe(
|
expect(url({ channel, date })).toBe(
|
||||||
'https://www.movistarplus.es/programacion-tv/sexta/2025-01-23'
|
'https://www.movistarplus.es/programacion-tv/sexta/2025-05-30'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', async () => {
|
||||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||||
const results = parser({ content, date }).map(p => {
|
|
||||||
|
axios.get.mockImplementation(url => {
|
||||||
|
if (
|
||||||
|
url ===
|
||||||
|
'https://www.movistarplus.es/entretenimiento/venta-prime-t1/ficha?tipo=E&id=3414523'
|
||||||
|
) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: fs.readFileSync(path.resolve(__dirname, '__data__/program1.html'))
|
||||||
|
})
|
||||||
|
} else if (
|
||||||
|
url ===
|
||||||
|
'https://www.movistarplus.es/deportes/programa/pokerstars-casino-1/ficha?tipo=E&id=2057641'
|
||||||
|
) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: fs.readFileSync(path.resolve(__dirname, '__data__/program2.html'))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return Promise.resolve({ data: '' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let results = await parser({ content, date })
|
||||||
|
results = results.map(p => {
|
||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(results.length).toBe(20)
|
expect(results.length).toBe(23)
|
||||||
expect(results[0]).toMatchObject({
|
expect(results[0]).toMatchObject({
|
||||||
start: '2025-01-23T05:00:00.000Z',
|
start: '2025-05-30T03:15:00.000Z',
|
||||||
stop: '2025-01-23T05:45:00.000Z',
|
stop: '2025-05-30T04:25:00.000Z',
|
||||||
title: 'Venta Prime'
|
title: 'Venta Prime',
|
||||||
|
description:
|
||||||
|
'Espacio de televenta.'
|
||||||
})
|
})
|
||||||
expect(results[19]).toMatchObject({
|
expect(results[19]).toMatchObject({
|
||||||
start: '2025-01-24T03:31:00.000Z',
|
start: '2025-05-31T00:45:00.000Z',
|
||||||
stop: '2025-01-24T05:00:00.000Z',
|
stop: '2025-05-31T01:25:00.000Z',
|
||||||
title: 'Minutos musicales'
|
title: 'Pokerstars casino',
|
||||||
|
description:
|
||||||
|
'El programa trae cada día toda la emoción de su ruleta en vivo, Spin & Win, una versión exclusiva del clásico juego de casino.'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
|
||||||
const result = parser({
|
it('can handle empty guide', async () => {
|
||||||
|
const results = await parser({
|
||||||
date,
|
date,
|
||||||
channel,
|
channel,
|
||||||
content: ''
|
content: '[]'
|
||||||
})
|
})
|
||||||
expect(result).toMatchObject([])
|
|
||||||
|
expect(results).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user