Files
iptv/tests/commands/playlist/test.test.ts

26 lines
830 B
TypeScript
Raw Normal View History

2025-03-15 07:29:59 +03:00
import { execSync } from 'child_process'
2025-04-23 20:56:11 +03:00
import os from 'node:os'
2025-03-15 07:29:59 +03:00
type ExecError = {
status: number
stdout: string
}
2025-07-10 21:12:54 +03:00
let ENV_VAR = 'ROOT_DIR=tests/__data__/input DATA_DIR=tests/__data__/input/data'
2025-04-22 03:47:28 +03:00
if (os.platform() === 'win32') {
2025-07-10 21:12:54 +03:00
ENV_VAR = 'SET "ROOT_DIR=tests/__data__/input" && SET "DATA_DIR=tests/__data__/input/data" &&'
2025-04-22 03:47:28 +03:00
}
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 {
2025-04-23 20:56:11 +03:00
execSync(cmd, { encoding: 'utf8' })
2025-04-22 03:47:28 +03:00
} catch (error) {
if (process.env.DEBUG === 'true') console.log(cmd, error)
2025-04-23 21:25:18 +03:00
expect((error as ExecError).stdout).toContain('playlist_test/ag.m3u')
2025-04-23 20:56:11 +03:00
expect((error as ExecError).stdout).toContain('2 problems (1 errors, 1 warnings)')
2025-04-22 03:47:28 +03:00
}
})
2025-03-15 07:29:59 +03:00
})