mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
54 lines
1.5 KiB
JavaScript
54 lines
1.5 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__/temp/database', { recursive: true })
|
|
fs.copyFileSync(
|
|
'tests/__data__/input/database/channels.db',
|
|
'tests/__data__/temp/database/channels.db'
|
|
)
|
|
fs.copyFileSync(
|
|
'tests/__data__/input/database/programs.db',
|
|
'tests/__data__/temp/database/programs.db'
|
|
)
|
|
|
|
const r = execSync(
|
|
'DB_DIR=tests/__data__/temp/database PUBLIC_DIR=tests/__data__/output node scripts/commands/update-guides.js',
|
|
{ encoding: 'utf8' }
|
|
)
|
|
console.log(r)
|
|
})
|
|
|
|
afterEach(() => {
|
|
fs.rmdirSync('tests/__data__/temp', { recursive: true })
|
|
})
|
|
|
|
fit('can generate epg.xml', () => {
|
|
const output = content('tests/__data__/output/epg.xml')
|
|
const expected = content('tests/__data__/expected/epg.xml')
|
|
|
|
expect(output).toBe(expected)
|
|
})
|
|
|
|
it('can generate /guides', () => {
|
|
const output1 = content('tests/__data__/output/guides/us/magticom.ge.epg.xml')
|
|
const expected1 = content('tests/__data__/expected/guides/us/magticom.ge.epg.xml')
|
|
|
|
expect(output1).toBe(expected1)
|
|
|
|
const output2 = content('tests/__data__/output/guides/za/dstv.com.epg.xml')
|
|
const expected2 = content('tests/__data__/expected/guides/za/dstv.com.epg.xml')
|
|
|
|
expect(output2).toBe(expected2)
|
|
})
|
|
|
|
function content(filepath) {
|
|
const data = fs.readFileSync(path.resolve(filepath), {
|
|
encoding: 'utf8'
|
|
})
|
|
|
|
return JSON.stringify(data)
|
|
}
|