mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-13 02:20:03 -04:00
Update tests
This commit is contained in:
parent
df365451a9
commit
6543464515
8 changed files with 175 additions and 111 deletions
|
@ -1,19 +1,28 @@
|
|||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import os from 'os'
|
||||
|
||||
let ENV_VAR =
|
||||
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/api_generate API_DIR=tests/__data__/output/.api'
|
||||
if (os.platform() === 'win32') {
|
||||
ENV_VAR =
|
||||
'SET "DATA_DIR=tests/__data__/input/data" && SET "STREAMS_DIR=tests/__data__/input/api_generate" && SET "API_DIR=tests/__data__/output/.api" &&'
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
})
|
||||
|
||||
it('can create streams.json', () => {
|
||||
execSync(
|
||||
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/api_generate API_DIR=tests/__data__/output/.api npm run api:generate',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
describe('api:generate', () => {
|
||||
it('can create streams.json', () => {
|
||||
const cmd = `${ENV_VAR} npm run 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('output/.api/streams.json')).toMatchObject(
|
||||
content('expected/api_generate/.api/streams.json')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue