epg-grabber/tests/programs.test.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-06-11 20:01:39 +02:00
import { parse as parsePrograms } from '../src/programs'
const channel = { xmltv_id: '1tv', lang: 'en' }
it('can parse programs', done => {
const config = {
parser: () => [
{
title: 'Title',
description: 'Description',
category: ['Category1', 'Category2'],
icon: 'https://example.com/image.jpg',
season: 9,
episode: 238,
2022-06-15 17:28:52 +02:00
start: 1640995200000,
stop: 1640998800000
2022-06-11 20:01:39 +02:00
}
]
}
parsePrograms({ channel, config })
.then(programs => {
expect(programs).toMatchObject([
{
title: 'Title',
description: 'Description',
category: ['Category1', 'Category2'],
icon: 'https://example.com/image.jpg',
season: 9,
episode: 238,
2022-06-15 17:28:52 +02:00
start: 1640995200000,
stop: 1640998800000,
2022-06-11 20:01:39 +02:00
channel: '1tv'
}
])
done()
})
.catch(done)
})
it('can parse programs async', done => {
const config = {
parser: async () => [
{
title: 'Title',
description: 'Description',
category: ['Category1', 'Category2'],
icon: 'https://example.com/image.jpg',
season: 9,
episode: 238,
2022-06-15 17:28:52 +02:00
start: 1640995200000,
stop: 1640998800000
2022-06-11 20:01:39 +02:00
}
]
}
parsePrograms({ channel, config })
.then(programs => {
expect(programs.length).toBe(1)
done()
})
.catch(done)
})