mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update update.test.js
This commit is contained in:
parent
ff6b08430d
commit
3c1ac2e326
1 changed files with 16 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
||||||
const { execSync } = require('child_process')
|
const { execSync } = require('child_process')
|
||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const glob = require('glob')
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
|
@ -14,13 +15,21 @@ it('can generate /guides', () => {
|
||||||
{ encoding: 'utf8' }
|
{ encoding: 'utf8' }
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guides/fr/chaines-tv.orange.fr.epg.xml')).toBe(
|
const guides = glob
|
||||||
content('tests/__data__/expected/guides/fr/chaines-tv.orange.fr.epg.xml')
|
.sync('tests/__data__/expected/guides/**/*.xml')
|
||||||
)
|
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guides/zw/dstv.com.epg.xml')).toBe(
|
guides.forEach(filepath => {
|
||||||
content('tests/__data__/expected/guides/zw/dstv.com.epg.xml')
|
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||||
)
|
})
|
||||||
|
|
||||||
|
const compressed = glob
|
||||||
|
.sync('tests/__data__/expected/guides/**/*.xml.gz')
|
||||||
|
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||||
|
|
||||||
|
compressed.forEach(filepath => {
|
||||||
|
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('will terminate process if programs not found', () => {
|
it('will terminate process if programs not found', () => {
|
||||||
|
@ -57,9 +66,7 @@ Error: No programs found
|
||||||
})
|
})
|
||||||
|
|
||||||
function content(filepath) {
|
function content(filepath) {
|
||||||
const data = fs.readFileSync(path.resolve(filepath), {
|
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
})
|
})
|
||||||
|
|
||||||
return JSON.stringify(data)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue