mirror of https://github.com/iptv-org/iptv
Update update-playlist.js
parent
c2b557c34c
commit
a728d3d5a5
@ -1,33 +1,29 @@
|
|||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const glob = require('glob')
|
||||||
const { execSync } = require('child_process')
|
const { execSync } = require('child_process')
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/temp')
|
fs.emptyDirSync('tests/__data__/temp')
|
||||||
fs.copyFileSync('tests/__data__/input/streams.db', 'tests/__data__/temp/streams.db')
|
fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/temp/streams.db')
|
||||||
|
|
||||||
const stdout = execSync(
|
const stdout = execSync('DB_DIR=tests/__data__/temp node scripts/commands/update-playlists.js', {
|
||||||
'DB_FILEPATH=tests/__data__/temp/streams.db node scripts/commands/update-playlists.js',
|
encoding: 'utf8'
|
||||||
{ encoding: 'utf8' }
|
})
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can update playlist', () => {
|
it('can update playlists', () => {
|
||||||
expect(content('tests/__data__/output/channels/ad.m3u')).toBe(
|
const files = glob
|
||||||
content('tests/__data__/expected/channels/ad.m3u')
|
.sync('tests/__data__/expected/channels/*.m3u')
|
||||||
)
|
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||||
|
|
||||||
expect(content('tests/__data__/output/channels/ru.m3u')).toBe(
|
files.forEach(filepath => {
|
||||||
content('tests/__data__/expected/channels/ru.m3u')
|
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||||
)
|
})
|
||||||
|
|
||||||
expect(content('tests/__data__/output/channels/uk.m3u')).toBe(
|
|
||||||
content('tests/__data__/expected/channels/uk.m3u')
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function content(filepath) {
|
function content(filepath) {
|
||||||
return fs.readFileSync(path.resolve(filepath), {
|
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue