From b67a9422848c25e781b8629d9a632c39caa0574e Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 26 Oct 2022 04:41:20 +0300 Subject: [PATCH] Update update.test.js --- tests/commands/guides/update.test.js | 41 ++++++++-------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/tests/commands/guides/update.test.js b/tests/commands/guides/update.test.js index 92b74ab8..fe47a2c9 100644 --- a/tests/commands/guides/update.test.js +++ b/tests/commands/guides/update.test.js @@ -6,23 +6,19 @@ const glob = require('glob') beforeEach(() => { fs.emptyDirSync('tests/__data__/output') fs.copyFileSync( - 'tests/__data__/input/database/update-guides/queue.db', - 'tests/__data__/output/queue.db' + 'tests/__data__/input/database/update-guides/programs.db', + 'tests/__data__/output/programs.db' + ) + + const stdout = execSync( + 'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output CURR_DATE=2022-10-20 npm run guides:update', + { encoding: 'utf8' } ) }) it('can generate /guides', () => { - fs.copyFileSync( - 'tests/__data__/input/database/update-guides/programs.db', - 'tests/__data__/output/programs.db' - ) - const stdout = execSync( - 'DB_DIR=tests/__data__/output DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output CURR_DATE=2022-05-05 npm run guides:update', - { encoding: 'utf8' } - ) - const uncompressed = glob - .sync('tests/__data__/expected/guides/**/*.epg.xml') + .sync('tests/__data__/expected/guides/*.xml') .map(f => f.replace('tests/__data__/expected/', '')) uncompressed.forEach(filepath => { @@ -30,7 +26,7 @@ it('can generate /guides', () => { }) const compressed = glob - .sync('tests/__data__/expected/guides/**/*.epg.xml.gz') + .sync('tests/__data__/expected/guides/*.xml.gz') .map(f => f.replace('tests/__data__/expected/', '')) compressed.forEach(filepath => { @@ -38,29 +34,16 @@ it('can generate /guides', () => { }) const json = glob - .sync('tests/__data__/expected/guides/**/*.json') + .sync('tests/__data__/expected/guides/*.json') .map(f => f.replace('tests/__data__/expected/', '')) json.forEach(filepath => { expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`)) }) -}) -it('will terminate process if programs not found', () => { - fs.copyFileSync( - 'tests/__data__/input/database/update-guides/no-programs.db', - 'tests/__data__/output/programs.db' + expect(content('output/logs/guides/update.log')).toEqual( + content('expected/logs/guides/update.log') ) - try { - const stdout = execSync( - 'DB_DIR=tests/__data__/output DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output npm run guides:update', - { encoding: 'utf8' } - ) - process.exit(1) - } catch (err) { - expect(err.status).toBe(1) - expect(err.stdout.includes('Error: No programs found')).toBe(true) - } }) function content(filepath) {