mirror of
https://github.com/iptv-org/iptv
synced 2025-12-16 18:37:17 -05:00
Update tests
This commit is contained in:
@@ -1,25 +1,33 @@
|
||||
import { execSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import { glob } from 'glob'
|
||||
import os from 'os'
|
||||
|
||||
let ENV_VAR = 'STREAMS_DIR=tests/__data__/output/streams'
|
||||
if (os.platform() === 'win32') {
|
||||
ENV_VAR = 'SET "STREAMS_DIR=tests/__data__/output/streams" &&'
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copySync('tests/__data__/input/playlist_format', 'tests/__data__/output/streams')
|
||||
})
|
||||
|
||||
it('can format playlists', () => {
|
||||
execSync('STREAMS_DIR=tests/__data__/output/streams npm run playlist:format', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
describe('playlist:format', () => {
|
||||
it('can format playlists', () => {
|
||||
const cmd = `${ENV_VAR} npm run playlist:format`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
|
||||
const files = glob
|
||||
.sync('tests/__data__/expected/playlist_format/*.m3u')
|
||||
.map(f => f.replace('tests/__data__/expected/playlist_format/', ''))
|
||||
const files = glob
|
||||
.sync('tests/__data__/expected/playlist_format/*.m3u')
|
||||
.map(f => f.replace('tests/__data__/expected/playlist_format/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/streams/${filepath}`), filepath).toBe(
|
||||
content(`expected/playlist_format/${filepath}`)
|
||||
)
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/streams/${filepath}`), filepath).toBe(
|
||||
content(`expected/playlist_format/${filepath}`)
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user