mirror of https://github.com/iptv-org/iptv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
760 B
TypeScript
29 lines
760 B
TypeScript
1 year ago
|
import { execSync } from 'child_process'
|
||
|
import fs from 'fs-extra'
|
||
3 years ago
|
|
||
|
beforeEach(() => {
|
||
|
fs.emptyDirSync('tests/__data__/output')
|
||
3 years ago
|
fs.mkdirSync('tests/__data__/output/database')
|
||
3 years ago
|
fs.copyFileSync(
|
||
2 years ago
|
'tests/__data__/input/database/api_generate.streams.db',
|
||
3 years ago
|
'tests/__data__/output/database/streams.db'
|
||
3 years ago
|
)
|
||
|
|
||
|
const stdout = execSync(
|
||
1 year ago
|
'DB_DIR=tests/__data__/output/database API_DIR=tests/__data__/output/.api npm run api:generate',
|
||
3 years ago
|
{ encoding: 'utf8' }
|
||
|
)
|
||
|
})
|
||
|
|
||
|
it('can create streams.json', () => {
|
||
2 years ago
|
expect(content(`output/.api/streams.json`)).toMatchObject(content(`expected/.api/streams.json`))
|
||
3 years ago
|
})
|
||
|
|
||
1 year ago
|
function content(filepath: string) {
|
||
3 years ago
|
return JSON.parse(
|
||
|
fs.readFileSync(`tests/__data__/${filepath}`, {
|
||
|
encoding: 'utf8'
|
||
|
})
|
||
|
)
|
||
3 years ago
|
}
|