Create bin.test.js

This commit is contained in:
Aleksandr Statciuk 2021-10-06 00:39:01 +03:00
parent c74b87f8dc
commit d20f0a75d8
1 changed files with 37 additions and 0 deletions

37
tests/bin.test.js Normal file
View File

@ -0,0 +1,37 @@
const { execSync } = require('child_process')
const pwd = `${__dirname}/..`
function stdoutResultTester(stdout) {
return [`Finish`].every(val => {
return RegExp(val).test(stdout)
})
}
it('can load config', () => {
const result = execSync(
`node ${pwd}/bin/epg-grabber.js --config=tests/input/example.com.config.js`,
{
encoding: 'utf8'
}
)
expect(stdoutResultTester(result)).toBe(true)
})
it('can load mini config', () => {
const result = execSync(
`node ${pwd}/bin/epg-grabber.js \
--config=tests/input/mini.config.js \
--channels=tests/input/example.com.channels.xml \
--output=tests/output/mini.guide.xml \
--lang=fr \
--days=3 \
--delay=5000`,
{
encoding: 'utf8'
}
)
expect(stdoutResultTester(result)).toBe(true)
expect(result.includes("File 'tests/output/mini.guide.xml' successfully saved")).toBe(true)
})