Add files via upload

This commit is contained in:
Ismaël Moret
2026-04-15 10:52:28 +02:00
committed by GitHub
parent 67c1a7e45e
commit 9c0093c098
29 changed files with 35200 additions and 2918 deletions
+20 -23
View File
@@ -10,47 +10,44 @@ dayjs.extend(utc)
jest.mock('axios')
const date = dayjs('2026-02-26', 'YYYY-MM-DD')
const channel = {
site_id: '62',
site_id: '42',
xmltv_id: 'Rai1HD.it'
}
it('can generate valid url for today', () => {
const date = dayjs.utc().startOf('d')
expect(url({ date })).toBe('https://www.tivu.tv/epg_ajax_sat.aspx?d=0')
expect(url({ channel, date })).toBe('https://services.tivulaguida.it/api/epg/channels/42/date/2026-02-26')
})
it('can generate valid url for tomorrow', () => {
const date = dayjs.utc().startOf('d').add(1, 'd')
expect(url({ date })).toBe('https://www.tivu.tv/epg_ajax_sat.aspx?d=1')
})
it('can parse response', async () => {
const date = dayjs.utc('2026-02-25', 'YYYY-MM-DD').startOf('d')
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
it('can parse response', () => {
const date = dayjs.utc('2022-10-04', 'YYYY-MM-DD').startOf('d')
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
let results = parser({ content, channel, date }).map(p => {
let results = await parser({ content, channel, date })
results = results.map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results[0]).toMatchObject({
start: '2022-10-03T22:02:00.000Z',
stop: '2022-10-03T22:45:00.000Z',
title: 'Cose Nostre - La figlia del boss'
start: '2026-02-25T05:00:00.000Z',
stop: '2026-02-25T05:28:00.000Z',
title: '1mattina News'
})
expect(results[43]).toMatchObject({
start: '2022-10-05T04:58:00.000Z',
stop: '2022-10-05T05:28:00.000Z',
title: 'Tgunomattina - in collaborazione con day'
expect(results[28]).toMatchObject({
start: '2026-02-25T22:56:00.000Z',
stop: '2026-02-26T00:15:00.000Z',
title: 'Festival di Sanremo'
})
})
it('can handle empty guide', () => {
const date = dayjs.utc('2022-10-04', 'YYYY-MM-DD').startOf('d')
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
const result = parser({ content, channel, date })
it('can handle empty guide', async () => {
const date = dayjs.utc('2026-02-25', 'YYYY-MM-DD').startOf('d')
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
const result = await parser({ content, channel, date })
expect(result).toMatchObject([])
})