mirror of
https://github.com/iptv-org/iptv
synced 2025-12-16 18:37:17 -05:00
Update tests
This commit is contained in:
36
tests/commands/playlist/generate.test.ts
Normal file
36
tests/commands/playlist/generate.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { execSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import * as glob from 'glob'
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/playlist_generate.streams.db',
|
||||
'tests/__data__/output/streams.db'
|
||||
)
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs npm run playlist:generate',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate playlists and logs', () => {
|
||||
const playlists = glob
|
||||
.sync('tests/__data__/expected/.gh-pages/**/*.m3u')
|
||||
.map((file: string) => file.replace('tests/__data__/expected/', ''))
|
||||
|
||||
playlists.forEach((filepath: string) => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
|
||||
expect(content(`output/logs/generators.log`).split('\n').sort()).toStrictEqual(
|
||||
content(`expected/logs/generators.log`).split('\n').sort()
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user