mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
const { execSync } = require('child_process')
|
|
|
|
beforeEach(() => {
|
|
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
|
fs.mkdirSync('tests/__data__/output')
|
|
fs.mkdirSync('tests/__data__/output/api')
|
|
})
|
|
|
|
it('can generate channels.json', () => {
|
|
const result = execSync(
|
|
'PUBLIC_DIR=tests/__data__/output DB_DIR=tests/__data__/input/database node scripts/commands/generate-guides.js',
|
|
{ encoding: 'utf8' }
|
|
)
|
|
const json = fs.readFileSync(path.resolve('tests/__data__/output/api/channels.json'), {
|
|
encoding: 'utf8'
|
|
})
|
|
const parsed = JSON.parse(json)
|
|
expect(parsed[0]).toMatchObject({
|
|
id: 'AndorraTV.ad',
|
|
name: ['Andorra TV'],
|
|
logo: null,
|
|
country: 'AD'
|
|
})
|
|
})
|
|
|
|
it('can generate programs.json', () => {
|
|
const result = execSync(
|
|
'PUBLIC_DIR=tests/__data__/output DB_DIR=tests/__data__/input/database node scripts/commands/generate-guides.js',
|
|
{ encoding: 'utf8' }
|
|
)
|
|
const json = fs.readFileSync(path.resolve('tests/__data__/output/api/programs.json'), {
|
|
encoding: 'utf8'
|
|
})
|
|
const parsed = JSON.parse(json)
|
|
const program = parsed['AndorraTV.ad'][0]
|
|
expect(Object.keys(program).sort()).toEqual([
|
|
'categories',
|
|
'channel',
|
|
'description',
|
|
'icons',
|
|
'site',
|
|
'start',
|
|
'stop',
|
|
'title'
|
|
])
|
|
})
|