mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create channels/parse.test.js
This commit is contained in:
parent
4cfbdaac3e
commit
c86d32c98d
4 changed files with 55 additions and 67 deletions
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="parse-channels.com">
|
||||
<channels>
|
||||
<channel lang="en" xmltv_id="CNNInternational.us" site_id="140">CNN International</channel>
|
||||
</channels>
|
||||
</site>
|
19
tests/__data__/input/sites/parse-channels.config.js
Normal file
19
tests/__data__/input/sites/parse-channels.config.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
site: 'parse-channels.com',
|
||||
url() {
|
||||
return `https://parse-channels.com`
|
||||
},
|
||||
parser() {
|
||||
return []
|
||||
},
|
||||
channels() {
|
||||
return [
|
||||
{
|
||||
lang: 'en',
|
||||
xmltv_id: 'CNNInternational.us',
|
||||
site_id: 140,
|
||||
name: 'CNN International'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
24
tests/commands/channels/parse.test.js
Normal file
24
tests/commands/channels/parse.test.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'npm run channels:parse -- --config=tests/__data__/input/sites/parse-channels.config.js --output=tests/__data__/output/channels.xml',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse channels', () => {
|
||||
expect(content('tests/__data__/output/channels.xml')).toEqual(
|
||||
content('tests/__data__/expected/sites/parse-channels.channels.xml')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
return fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue