diff --git a/tests/commands/playlist/format.test.ts b/tests/commands/playlist/format.test.ts index 070bfd7d9..f6c631252 100644 --- a/tests/commands/playlist/format.test.ts +++ b/tests/commands/playlist/format.test.ts @@ -20,9 +20,12 @@ describe('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(filepath => { + const fileUrl = pathToFileURL(filepath).toString() + const pathToRemove = pathToFileURL('tests/__data__/expected/playlist_format/').toString() + + return fileUrl.replace(pathToRemove, '') + }) files.forEach(filepath => { expect(content(`tests/__data__/output/streams/${filepath}`), filepath).toBe( diff --git a/tests/commands/playlist/generate.test.ts b/tests/commands/playlist/generate.test.ts index 5c99f0269..fa27be5b1 100644 --- a/tests/commands/playlist/generate.test.ts +++ b/tests/commands/playlist/generate.test.ts @@ -23,7 +23,12 @@ describe('playlist:generate', () => { const playlists = glob .sync('tests/__data__/expected/playlist_generate/.gh-pages/**/*.m3u') - .map((file: string) => file.replace('tests/__data__/expected/playlist_generate/', '')) + .map(filepath => { + const fileUrl = pathToFileURL(filepath).toString() + const pathToRemove = pathToFileURL('tests/__data__/expected/playlist_generate/').toString() + + return fileUrl.replace(pathToRemove, '') + }) playlists.forEach((filepath: string) => { expect(content(`tests/__data__/output/${filepath}`), filepath).toBe( diff --git a/tests/commands/playlist/test.test.ts b/tests/commands/playlist/test.test.ts index 0020106dc..1b42c3d58 100644 --- a/tests/commands/playlist/test.test.ts +++ b/tests/commands/playlist/test.test.ts @@ -1,4 +1,5 @@ import { execSync } from 'child_process' +import path from 'node:path' import os from 'os' type ExecError = { @@ -27,6 +28,10 @@ describe('playlist:test', () => { }) function checkStdout(stdout: string) { - expect(stdout).toContain('playlist_test/ag.m3u') + 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) +}