mirror of
https://github.com/iptv-org/iptv.git
synced 2024-12-27 10:07:10 +00:00
Create format.test.js
This commit is contained in:
parent
61e5559061
commit
78038b9505
32
tests/commands/playlist/format.test.js
Normal file
32
tests/commands/playlist/format.test.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/playlist_format.streams.db',
|
||||
'tests/__data__/output/streams.db'
|
||||
)
|
||||
|
||||
const stdout = execSync('DB_DIR=tests/__data__/output npm run playlist:format', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
})
|
||||
|
||||
it('can format playlists', () => {
|
||||
const files = glob
|
||||
.sync('tests/__data__/expected/streams/*.m3u')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue