mirror of
https://github.com/iptv-org/database.git
synced 2024-11-29 21:59:35 -05:00
24 lines
637 B
TypeScript
24 lines
637 B
TypeScript
import { execSync } from 'child_process'
|
|
import * as fs from 'fs-extra'
|
|
|
|
beforeEach(() => {
|
|
fs.emptyDirSync('tests/__data__/output')
|
|
})
|
|
|
|
it('can export data as json', () => {
|
|
execSync(
|
|
'DATA_DIR=tests/__data__/input/data API_DIR=tests/__data__/output/api npm run db:export',
|
|
{
|
|
encoding: 'utf8'
|
|
}
|
|
)
|
|
|
|
expect(content('output/api/blocklist.json')).toEqual(content('expected/api/blocklist.json'))
|
|
expect(content('output/api/channels.json')).toEqual(content('expected/api/channels.json'))
|
|
})
|
|
|
|
function content(filepath: string) {
|
|
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
|
encoding: 'utf8'
|
|
})
|
|
}
|