mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-13 02:20:03 -04:00
Update save-results.js
This commit is contained in:
parent
9a4aea7949
commit
fa4bad3dca
9 changed files with 215 additions and 359 deletions
36
tests/commands/save-results.test.js
Normal file
36
tests/commands/save-results.test.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/temp')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/save-results.channels.db',
|
||||
'tests/__data__/temp/channels.db'
|
||||
)
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_FILEPATH=tests/__data__/temp/channels.db LOGS_PATH=tests/__data__/input/logs/load-streams EPG_CODES_FILEPATH=tests/__data__/input/codes.json node scripts/commands/save-results.js',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can save results', () => {
|
||||
const output = content('tests/__data__/temp/channels.db')
|
||||
const expected = content('tests/__data__/expected/save-results.channels.db')
|
||||
|
||||
expect(output).toEqual(expected)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return data
|
||||
.split('\n')
|
||||
.filter(l => l)
|
||||
.map(l => {
|
||||
return JSON.parse(l)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue