From 0a83492b76553110bee3bc36e8c5c77766410c22 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 11 May 2023 04:12:44 +0300 Subject: [PATCH] Update bin.test.js --- tests/bin.test.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/bin.test.js b/tests/bin.test.js index 9e2404b..b67b290 100644 --- a/tests/bin.test.js +++ b/tests/bin.test.js @@ -1,5 +1,5 @@ const { execSync } = require('child_process') -const fs = require('fs') +const fs = require('fs-extra') const path = require('path') const epgParser = require('epg-parser') @@ -11,6 +11,10 @@ function stdoutResultTester(stdout) { }) } +beforeEach(() => { + fs.emptyDirSync('tests/__data__/output') +}) + it('can load config', () => { const stdout = execSync( `node ${pwd}/bin/epg-grabber.js --config=tests/__data__/input/example.config.js --delay=0`, @@ -62,6 +66,26 @@ it('can generate gzip version', () => { ) }) +it('can produce multiple outputs', () => { + const stdout = execSync( + `node ${pwd}/bin/epg-grabber.js \ + --config=tests/__data__/input/mini.config.js \ + --channels=tests/__data__/input/example.channels.xml \ + --output=tests/__data__/output/{lang}/{id}.xml`, + { + encoding: 'utf8' + } + ) + + expect(stdoutResultTester(stdout)).toBe(true) + expect(stdout.includes("File 'tests/__data__/output/fr/1TV.com.xml' successfully saved")).toBe( + true + ) + expect( + stdout.includes("File 'tests/__data__/output/undefined/2TV.com.xml' successfully saved") + ).toBe(true) +}) + it('removes duplicates of the program', () => { const stdout = execSync( `node ${pwd}/bin/epg-grabber.js \