mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
wip
This commit is contained in:
parent
299cf26cd6
commit
ce525ed13c
13 changed files with 199 additions and 207 deletions
|
@ -5,47 +5,38 @@ const { execSync } = require('child_process')
|
|||
beforeEach(() => {
|
||||
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
||||
fs.mkdirSync('tests/__data__/output')
|
||||
fs.mkdirSync('tests/__data__/output/api')
|
||||
|
||||
execSync(
|
||||
'PUBLIC_DIR=tests/__data__/output DB_DIR=tests/__data__/input/database node scripts/commands/generate-guides.js',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
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'
|
||||
})
|
||||
const output = content('tests/__data__/output/api/channels.json')
|
||||
const expected = content('tests/__data__/expected/api/channels.json')
|
||||
|
||||
expect(output).toBe(expected)
|
||||
})
|
||||
|
||||
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'), {
|
||||
const output = content('tests/__data__/output/api/programs.json')
|
||||
const expected = content('tests/__data__/expected/api/programs.json')
|
||||
|
||||
expect(output).toBe(expected)
|
||||
})
|
||||
|
||||
it('can generate epg.xml', () => {
|
||||
const output = content('tests/__data__/output/guides/epg.xml')
|
||||
const expected = content('tests/__data__/expected/guides/epg.xml')
|
||||
|
||||
expect(output).toBe(expected)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
const parsed = JSON.parse(json)
|
||||
const program = parsed['AndorraTV.ad'][0]
|
||||
expect(Object.keys(program).sort()).toEqual([
|
||||
'categories',
|
||||
'channel',
|
||||
'description',
|
||||
'image',
|
||||
'start',
|
||||
'stop',
|
||||
'title'
|
||||
])
|
||||
expect(Array.isArray(program.title)).toBe(true)
|
||||
expect(Array.isArray(program.description)).toBe(true)
|
||||
expect(Array.isArray(program.categories)).toBe(true)
|
||||
expect(program.image === null || typeof program.image === 'string').toBe(true)
|
||||
})
|
||||
|
||||
return JSON.stringify(data)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue