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(
|
2021-10-13 21:52:49 +02:00
|
|
|
`node ${pwd}/bin/epg-grabber.js --config=tests/input/example.com.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 \
|
|
|
|
--channels=tests/input/example.com.channels.xml \
|
|
|
|
--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 \
|
|
|
|
--channels=tests/input/example.com.channels.xml \
|
|
|
|
--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)
|
|
|
|
})
|