2025-09-28 17:55:05 +03:00
|
|
|
const { parser, url } = require('./musor.tv.config.js')
|
|
|
|
|
const fs = require('fs')
|
|
|
|
|
const path = require('path')
|
|
|
|
|
const dayjs = require('dayjs')
|
|
|
|
|
const utc = require('dayjs/plugin/utc')
|
|
|
|
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
|
|
|
|
|
|
|
|
dayjs.extend(customParseFormat)
|
|
|
|
|
dayjs.extend(utc)
|
|
|
|
|
|
2025-10-12 14:44:12 +02:00
|
|
|
const date = dayjs.utc('2025-10-11', 'YYYY-MM-DD').startOf('d')
|
2025-09-28 17:55:05 +03:00
|
|
|
const channel = {
|
2025-10-12 14:44:12 +02:00
|
|
|
site_id: 'MAGYAR_MOZI_TV',
|
|
|
|
|
xmltv_id: 'MagyarMoziTV.hu',
|
2025-09-28 17:55:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it('can generate valid url', () => {
|
2025-10-12 14:44:12 +02:00
|
|
|
expect(url({ channel, date })).toBe('https://musor.tv/napi/tvmusor/MAGYAR_MOZI_TV/2025.10.11')
|
2025-09-28 17:55:05 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('can generate valid url for today', () => {
|
|
|
|
|
const today = dayjs.utc().startOf('d')
|
|
|
|
|
|
2025-10-12 14:44:12 +02:00
|
|
|
expect(url({ channel, date: today })).toBe('https://musor.tv/mai/tvmusor/MAGYAR_MOZI_TV')
|
2025-09-28 17:55:05 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('can parse response', () => {
|
|
|
|
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
|
|
|
|
const results = parser({ content, date }).map(p => {
|
|
|
|
|
p.start = p.start.toJSON()
|
|
|
|
|
p.stop = p.stop.toJSON()
|
|
|
|
|
return p
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(results[0]).toMatchObject({
|
2025-10-12 14:44:12 +02:00
|
|
|
start: '2025-10-10T23:05:00.000Z',
|
|
|
|
|
stop: '2025-10-11T00:50:00.000Z',
|
|
|
|
|
title: 'A 25. év - Három rohadék rockcsempész (Tankcsapda road movie)',
|
|
|
|
|
description: 'Lévai Balázs több mint egy éven át forgatott a Tankcsapdával.'
|
2025-09-28 17:55:05 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(results[1]).toMatchObject({
|
2025-10-12 14:44:12 +02:00
|
|
|
start: '2025-10-11T00:50:00.000Z',
|
|
|
|
|
stop: '2025-10-11T01:45:00.000Z',
|
|
|
|
|
title: 'Megbélyegzetten - 1968',
|
|
|
|
|
description: 'Néhány tinédzser diák, egy csalinak szánt újságcikk nyomán levelet írt Ausztriába 1968-ban.'
|
2025-09-28 17:55:05 +03:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('can handle empty guide', () => {
|
|
|
|
|
const result = parser({
|
|
|
|
|
date,
|
|
|
|
|
content: '<!DOCTYPE html><html><head></head><body></body></html>'
|
|
|
|
|
})
|
|
|
|
|
expect(result).toMatchObject([])
|
|
|
|
|
})
|