iptv/tests/commands/database/export.test.js

26 lines
659 B
JavaScript
Raw Normal View History

2022-02-12 23:40:45 +01:00
const { execSync } = require('child_process')
const fs = require('fs-extra')
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.copyFileSync(
2022-02-13 03:42:39 +01:00
'tests/__data__/input/database/db_export.streams.db',
2022-02-12 23:40:45 +01:00
'tests/__data__/output/streams.db'
)
const stdout = execSync(
2022-02-13 09:50:57 +01:00
'DB_DIR=tests/__data__/output PUBLIC_DIR=tests/__data__/output/.api npm run db:export',
2022-02-12 23:40:45 +01:00
{ encoding: 'utf8' }
)
})
it('can create streams.json', () => {
2022-02-13 09:50:57 +01:00
expect(content(`output/.api/streams.json`)).toBe(content(`expected/.api/streams.json`))
2022-02-12 23:40:45 +01:00
})
function content(filepath) {
return fs.readFileSync(`tests/__data__/${filepath}`, {
encoding: 'utf8'
})
}