mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-13 10:30:03 -04:00
Update tests
This commit is contained in:
parent
ddedd67b80
commit
23342a24bb
3 changed files with 18 additions and 5 deletions
|
@ -20,9 +20,12 @@ describe('playlist:format', () => {
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
|
|
||||||
const files = glob
|
const files = glob.sync('tests/__data__/expected/playlist_format/*.m3u').map(filepath => {
|
||||||
.sync('tests/__data__/expected/playlist_format/*.m3u')
|
const fileUrl = pathToFileURL(filepath).toString()
|
||||||
.map(f => f.replace('tests/__data__/expected/playlist_format/', ''))
|
const pathToRemove = pathToFileURL('tests/__data__/expected/playlist_format/').toString()
|
||||||
|
|
||||||
|
return fileUrl.replace(pathToRemove, '')
|
||||||
|
})
|
||||||
|
|
||||||
files.forEach(filepath => {
|
files.forEach(filepath => {
|
||||||
expect(content(`tests/__data__/output/streams/${filepath}`), filepath).toBe(
|
expect(content(`tests/__data__/output/streams/${filepath}`), filepath).toBe(
|
||||||
|
|
|
@ -23,7 +23,12 @@ describe('playlist:generate', () => {
|
||||||
|
|
||||||
const playlists = glob
|
const playlists = glob
|
||||||
.sync('tests/__data__/expected/playlist_generate/.gh-pages/**/*.m3u')
|
.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) => {
|
playlists.forEach((filepath: string) => {
|
||||||
expect(content(`tests/__data__/output/${filepath}`), filepath).toBe(
|
expect(content(`tests/__data__/output/${filepath}`), filepath).toBe(
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
|
import path from 'node:path'
|
||||||
import os from 'os'
|
import os from 'os'
|
||||||
|
|
||||||
type ExecError = {
|
type ExecError = {
|
||||||
|
@ -27,6 +28,10 @@ describe('playlist:test', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
function checkStdout(stdout: string) {
|
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)')
|
expect(stdout).toContain('2 problems (1 errors, 1 warnings)')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function slash(filepath: string) {
|
||||||
|
return filepath.split(path.sep).join(path.posix.sep)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue