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 path = require('path')
|
||||
const glob = require('glob')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
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(
|
||||
'DB_FILEPATH=tests/__data__/temp/streams.db node scripts/commands/update-playlists.js',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
const stdout = execSync('DB_DIR=tests/__data__/temp node scripts/commands/update-playlists.js', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
})
|
||||
|
||||
it('can update playlist', () => {
|
||||
expect(content('tests/__data__/output/channels/ad.m3u')).toBe(
|
||||
content('tests/__data__/expected/channels/ad.m3u')
|
||||
)
|
||||
it('can update playlists', () => {
|
||||
const files = glob
|
||||
.sync('tests/__data__/expected/channels/*.m3u')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
expect(content('tests/__data__/output/channels/ru.m3u')).toBe(
|
||||
content('tests/__data__/expected/channels/ru.m3u')
|
||||
)
|
||||
|
||||
expect(content('tests/__data__/output/channels/uk.m3u')).toBe(
|
||||
content('tests/__data__/expected/channels/uk.m3u')
|
||||
)
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
return fs.readFileSync(path.resolve(filepath), {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue