From f087f4640f932cc2896cff122641de5245ca494e Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 15 Sep 2021 11:19:58 +0300 Subject: [PATCH] Create index.test.js --- tests/index.test.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/index.test.js diff --git a/tests/index.test.js b/tests/index.test.js new file mode 100644 index 0000000..1132fdf --- /dev/null +++ b/tests/index.test.js @@ -0,0 +1,34 @@ +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}/src/index.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}/src/index.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) +})