mirror of
https://github.com/iptv-org/iptv
synced 2025-12-16 02:16:47 -05:00
31 lines
880 B
TypeScript
31 lines
880 B
TypeScript
import { execSync } from 'child_process'
|
|
import path from 'node:path'
|
|
import os from 'node:os'
|
|
|
|
type ExecError = {
|
|
status: number
|
|
stdout: string
|
|
}
|
|
|
|
let ENV_VAR = 'ROOT_DIR=tests/__data__/input'
|
|
if (os.platform() === 'win32') {
|
|
ENV_VAR = 'SET "ROOT_DIR=tests/__data__/input" &&'
|
|
}
|
|
|
|
describe('playlist:test', () => {
|
|
it('shows an error if the playlist contains a broken link', () => {
|
|
const cmd = `${ENV_VAR} npm run playlist:test playlist_test/ag.m3u`
|
|
try {
|
|
execSync(cmd, { encoding: 'utf8' })
|
|
} catch (error) {
|
|
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
|
expect((error as ExecError).stdout).toContain(slash('playlist_test/ag.m3u'))
|
|
expect((error as ExecError).stdout).toContain('2 problems (1 errors, 1 warnings)')
|
|
}
|
|
})
|
|
})
|
|
|
|
function slash(filepath: string) {
|
|
return filepath.split(path.sep).join(path.posix.sep)
|
|
}
|