mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-11 09:30:03 -04:00
Update tests
This commit is contained in:
parent
6543464515
commit
2841068ca0
5 changed files with 20 additions and 29 deletions
|
@ -1,3 +1,4 @@
|
|||
import { pathToFileURL } from 'node:url'
|
||||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import os from 'os'
|
||||
|
@ -19,16 +20,12 @@ describe('api:generate', () => {
|
|||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
|
||||
expect(content('output/.api/streams.json')).toMatchObject(
|
||||
content('expected/api_generate/.api/streams.json')
|
||||
expect(content('tests/__data__/output/.api/streams.json')).toMatchObject(
|
||||
content('tests/__data__/expected/api_generate/.api/streams.json')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return JSON.parse(
|
||||
fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
)
|
||||
return JSON.parse(fs.readFileSync(pathToFileURL(filepath), { encoding: 'utf8' }))
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { pathToFileURL } from 'node:url'
|
||||
import { execSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import { glob } from 'glob'
|
||||
|
@ -24,15 +25,13 @@ describe('playlist:format', () => {
|
|||
.map(f => f.replace('tests/__data__/expected/playlist_format/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/streams/${filepath}`), filepath).toBe(
|
||||
content(`expected/playlist_format/${filepath}`)
|
||||
expect(content(`tests/__data__/output/streams/${filepath}`), filepath).toBe(
|
||||
content(`tests/__data__/expected/playlist_format/${filepath}`)
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
return fs.readFileSync(pathToFileURL(filepath), { encoding: 'utf8' })
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { pathToFileURL } from 'node:url'
|
||||
import { execSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import * as glob from 'glob'
|
||||
|
@ -25,19 +26,17 @@ describe('playlist:generate', () => {
|
|||
.map((file: string) => file.replace('tests/__data__/expected/playlist_generate/', ''))
|
||||
|
||||
playlists.forEach((filepath: string) => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(
|
||||
content(`expected/playlist_generate/${filepath}`)
|
||||
expect(content(`tests/__data__/output/${filepath}`), filepath).toBe(
|
||||
content(`tests/__data__/expected/playlist_generate/${filepath}`)
|
||||
)
|
||||
})
|
||||
|
||||
expect(content('output/logs/generators.log').split('\n').sort()).toStrictEqual(
|
||||
content('expected/playlist_generate/logs/generators.log').split('\n').sort()
|
||||
expect(content('tests/__data__/output/logs/generators.log').split('\n').sort()).toStrictEqual(
|
||||
content('tests/__data__/expected/playlist_generate/logs/generators.log').split('\n').sort()
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
return fs.readFileSync(pathToFileURL(filepath), { encoding: 'utf8' })
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { pathToFileURL } from 'node:url'
|
||||
import { execSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import { glob } from 'glob'
|
||||
|
@ -25,8 +26,8 @@ describe('playlist:update', () => {
|
|||
.map(f => f.replace('tests/__data__/expected/playlist_update/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/streams/${filepath}`), filepath).toBe(
|
||||
content(`expected/playlist_update/${filepath}`)
|
||||
expect(content(`tests/__data__/output/streams/${filepath}`), filepath).toBe(
|
||||
content(`tests/__data__/expected/playlist_update/${filepath}`)
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -37,7 +38,5 @@ describe('playlist:update', () => {
|
|||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
return fs.readFileSync(pathToFileURL(filepath), { encoding: 'utf8' })
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { pathToFileURL } from 'node:url'
|
||||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
|
@ -36,9 +37,5 @@ describe('readme:update', () => {
|
|||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return JSON.stringify(data)
|
||||
return JSON.stringify(fs.readFileSync(pathToFileURL(filepath), { encoding: 'utf8' }))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue