mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 18:10:04 -04:00
Update tests
This commit is contained in:
parent
708744b28f
commit
8a83f23243
10 changed files with 151 additions and 116 deletions
28
tests/commands/api/generate.test.ts
Normal file
28
tests/commands/api/generate.test.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.mkdirSync('tests/__data__/output/database')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/api_generate.streams.db',
|
||||
'tests/__data__/output/database/streams.db'
|
||||
)
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output/database API_DIR=tests/__data__/output/.api npm run api:generate',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can create streams.json', () => {
|
||||
expect(content(`output/.api/streams.json`)).toMatchObject(content(`expected/.api/streams.json`))
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return JSON.parse(
|
||||
fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue