Files
epg/sites/sky.com/sky.com.test.js

62 lines
2.1 KiB
JavaScript
Raw Normal View History

2023-10-15 14:08:23 +03:00
const { parser, url } = require('./sky.com.config.js')
const fs = require('fs')
const path = require('path')
2023-10-15 14:08:23 +03:00
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
2023-10-15 14:08:23 +03:00
dayjs.extend(customParseFormat)
dayjs.extend(utc)
const date = dayjs.utc('2024-12-14', 'YYYY-MM-DD').startOf('d')
2023-10-15 14:08:23 +03:00
const channel = {
site_id: '4086',
xmltv_id: 'SkyHistoryHD.uk'
2023-10-15 14:08:23 +03:00
}
it('can generate valid url', () => {
2025-01-01 12:27:22 +03:00
expect(url({ channel, date })).toBe('https://awk.epgsky.com/hawk/linear/schedule/20241214/4086')
2023-10-15 14:08:23 +03:00
})
it('can parse response', () => {
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.json'))
2023-10-15 14:08:23 +03:00
const result = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result.length).toBe(31)
expect(result[0]).toMatchObject({
start: '2024-12-14T00:00:00.000Z',
stop: '2024-12-14T00:30:00.000Z',
title: 'Storage Wars',
description:
'A Sale Of Two Cities: Emily brings her mother along with her to Walnut, and Darrell wastes no time finding an advantage. Ivy and Ivy jr clean up with their locker. (S12, ep 4)',
season: 12,
2025-03-04 17:21:45 +00:00
episode: 4,
2025-03-05 02:17:22 +03:00
icon: 'https://images.metadata.sky.com/pd-image/b9572a38-8db7-471e-a2d7-462e1dd26af2/16-9/640',
image: 'https://images.metadata.sky.com/pd-image/b9572a38-8db7-471e-a2d7-462e1dd26af2/16-9/640'
})
expect(result[2]).toMatchObject({
start: '2024-12-14T01:00:00.000Z',
stop: '2024-12-14T01:30:00.000Z',
title: 'Storage Wars',
description:
'Not All That Glitters Is Gourd: Back in the city of Orange, the Vegas Ladies arrive in vintage style - though not everyone agrees. (S12, ep 6)',
season: 12,
2025-03-04 17:21:45 +00:00
episode: 6,
2025-03-05 02:17:22 +03:00
icon: 'https://images.metadata.sky.com/pd-image/e9521ccc-bdcc-4075-9c2e-bc835247148b/16-9/640',
image: 'https://images.metadata.sky.com/pd-image/e9521ccc-bdcc-4075-9c2e-bc835247148b/16-9/640'
})
2023-10-15 14:08:23 +03:00
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: ''
2023-10-15 14:08:23 +03:00
})
expect(result).toMatchObject([])
})