epg-grabber/tests/bin.test.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-10-05 23:39:01 +02:00
const { execSync } = require('child_process')
2021-11-18 15:31:54 +01:00
2022-01-16 15:34:21 +01:00
const pwd = `${__dirname}/..`
2021-10-05 23:39:01 +02:00
function stdoutResultTester(stdout) {
return [`Finish`].every(val => {
return RegExp(val).test(stdout)
})
}
it('can load config', () => {
const result = execSync(
2022-06-16 14:07:56 +02:00
`node ${pwd}/bin/epg-grabber.js --config=tests/input/example.config.js --delay=0`,
2021-10-05 23:39:01 +02:00
{
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 \
2022-06-16 14:07:56 +02:00
--channels=tests/input/example.channels.xml \
2021-10-05 23:39:01 +02:00
--output=tests/output/mini.guide.xml \
--lang=fr \
--days=3 \
2021-11-18 15:31:54 +01:00
--delay=0 \
2022-01-16 15:34:21 +01:00
--debug \
--timeout=1`,
2021-10-05 23:39:01 +02:00
{
encoding: 'utf8'
}
)
expect(stdoutResultTester(result)).toBe(true)
expect(result.includes("File 'tests/output/mini.guide.xml' successfully saved")).toBe(true)
})
2022-03-15 12:52:55 +01:00
it('can generate gzip version', () => {
const result = execSync(
`node ${pwd}/bin/epg-grabber.js \
--config=tests/input/mini.config.js \
2022-06-16 14:07:56 +02:00
--channels=tests/input/example.channels.xml \
2022-03-15 12:52:55 +01:00
--output=tests/output/mini.guide.xml.gz \
--gzip`,
{
encoding: 'utf8'
}
)
expect(stdoutResultTester(result)).toBe(true)
expect(result.includes("File 'tests/output/mini.guide.xml.gz' successfully saved")).toBe(true)
})