mirror of
https://github.com/iptv-org/database.git
synced 2025-05-11 04:00:01 -04:00
Create tests
This commit is contained in:
parent
d5e243aca4
commit
66ec908b6e
3 changed files with 124 additions and 0 deletions
24
tests/db/export.test.ts
Normal file
24
tests/db/export.test.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
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'
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue