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 => {
|
const programs = result.programs.map(program => {
|
||||||
program.site = result.site
|
program.site = result.site
|
||||||
program.country = result.country
|
program.country = result.country
|
||||||
|
program.gid = result.gid
|
||||||
|
|
||||||
return program
|
return program
|
||||||
})
|
})
|
||||||
|
|
|
@ -13,18 +13,15 @@ beforeEach(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can save results to database', () => {
|
it('can save results to database', () => {
|
||||||
const output = fs.readFileSync(path.resolve('tests/__data__/output/database/programs.db'), {
|
const output = content('tests/__data__/output/database/programs.db')
|
||||||
encoding: 'utf8'
|
|
||||||
})
|
|
||||||
const lines = output.split('\n')
|
|
||||||
const parsed = JSON.parse(lines[0])
|
|
||||||
|
|
||||||
expect(Object.keys(parsed).sort()).toEqual([
|
expect(Object.keys(output[0]).sort()).toEqual([
|
||||||
'_id',
|
'_id',
|
||||||
'category',
|
'category',
|
||||||
'channel',
|
'channel',
|
||||||
'country',
|
'country',
|
||||||
'description',
|
'description',
|
||||||
|
'gid',
|
||||||
'icon',
|
'icon',
|
||||||
'lang',
|
'lang',
|
||||||
'site',
|
'site',
|
||||||
|
@ -33,3 +30,16 @@ it('can save results to database', () => {
|
||||||
'title'
|
'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