Update tests

This commit is contained in:
freearhey
2025-04-23 20:56:11 +03:00
parent e82155e38e
commit 7f78b5770e
4 changed files with 24 additions and 34 deletions

View File

@@ -1,6 +1,6 @@
import { execSync } from 'child_process'
import path from 'node:path'
import os from 'os'
import os from 'node:os'
type ExecError = {
status: number
@@ -16,22 +16,15 @@ 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 {
const stdout = execSync(cmd, { encoding: 'utf8' })
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
checkStdout(stdout)
execSync(cmd, { encoding: 'utf8' })
} catch (error) {
// NOTE: for Windows only
if (process.env.DEBUG === 'true') console.log(cmd, error)
checkStdout((error as ExecError).stdout)
expect((error as ExecError).stdout).toContain(slash('playlist_test/ag.m3u'))
expect((error as ExecError).stdout).toContain('2 problems (1 errors, 1 warnings)')
}
})
})
function checkStdout(stdout: string) {
expect(stdout).toContain(slash('playlist_test/ag.m3u'))
expect(stdout).toContain('2 problems (1 errors, 1 warnings)')
}
function slash(filepath: string) {
return filepath.split(path.sep).join(path.posix.sep)
}