mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update save-results.js
This commit is contained in:
parent
b3413b6c99
commit
3e4a24b42f
2 changed files with 17 additions and 6 deletions
|
@ -12,6 +12,7 @@ async function main() {
|
|||
const programs = result.programs.map(program => {
|
||||
program.site = result.site
|
||||
program.country = result.country
|
||||
program.gid = result.gid
|
||||
|
||||
return program
|
||||
})
|
||||
|
|
|
@ -13,18 +13,15 @@ beforeEach(() => {
|
|||
})
|
||||
|
||||
it('can save results to database', () => {
|
||||
const output = fs.readFileSync(path.resolve('tests/__data__/output/database/programs.db'), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
const lines = output.split('\n')
|
||||
const parsed = JSON.parse(lines[0])
|
||||
const output = content('tests/__data__/output/database/programs.db')
|
||||
|
||||
expect(Object.keys(parsed).sort()).toEqual([
|
||||
expect(Object.keys(output[0]).sort()).toEqual([
|
||||
'_id',
|
||||
'category',
|
||||
'channel',
|
||||
'country',
|
||||
'description',
|
||||
'gid',
|
||||
'icon',
|
||||
'lang',
|
||||
'site',
|
||||
|
@ -33,3 +30,16 @@ it('can save results to database', () => {
|
|||
'title'
|
||||
])
|
||||
})
|
||||
|
||||
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