From 3fe2a921b7487b7bd01d2f5ec8fcf717cf7bf479 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Fri, 9 Jan 2015 01:58:42 +0300 Subject: [PATCH] CLI: correct tests for the "reporter" option Assertion for the "reporter" option actually didn't test anything --- lib/cli.js | 1 + test/cli.js | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 234d7d6a7..a163dc77b 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -82,6 +82,7 @@ module.exports = function(program) { reporterPath = './reporters/' + ( program.colors && supportsColor ? 'console' : 'text' ); + returnArgs.reporter = reporterPath; } try { diff --git a/test/cli.js b/test/cli.js index 257bd2f1c..e2c857b96 100644 --- a/test/cli.js +++ b/test/cli.js @@ -276,7 +276,7 @@ describe('modules/cli', function() { it('should not fail with additional args supplied: `cat myEmptyFile.js | jscs -n`', function() { var result = cli({ args: [], - 'no-colors': true, + colors: true, config: 'test/data/cli/cli.json' }); @@ -318,27 +318,33 @@ describe('modules/cli', function() { }); describe('reporter option', function() { - it('should set implicitly set checkstyle reporter', function() { + it('should implicitly set console reporter', function() { var result = cli({ args: ['test/data/cli/error.js'], + colors: true, config: 'test/data/cli/cli.json' }); return result.promise.always(function() { - assert(path.basename(result.reporter), 'checkstyle'); + assert.equal(path.basename(result.reporter), 'console'); rAfter(); }); }); - it('should set implicitly set text reporter', function() { + it('should implicitly set text reporter', function() { + var old = cli.__get__('supportsColor'); + + cli.__set__('supportsColor', false); + var result = cli({ args: ['test/data/cli/error.js'], - 'no-colors': true, + colors: true, config: 'test/data/cli/cli.json' }); return result.promise.always(function() { - assert(path.basename(result.reporter), 'text.js'); + assert.equal(path.basename(result.reporter), 'text'); + cli.__set__('supportsColor', old); rAfter(); }); }); @@ -353,7 +359,7 @@ describe('modules/cli', function() { }); return result.promise.always(function() { - assert(path.basename(result.reporter), 'junit.js'); + assert.equal(path.basename(result.reporter), 'junit.js'); rAfter(); }); }); @@ -366,7 +372,7 @@ describe('modules/cli', function() { }); return result.promise.always(function() { - assert(path.basename(result.reporter), 'junit.js'); + assert.equal(path.basename(result.reporter), 'junit.js'); rAfter(); }); }); @@ -379,7 +385,7 @@ describe('modules/cli', function() { }); return result.promise.always(function() { - assert(path.basename(result.reporter), 'text.js'); + assert.equal(path.basename(result.reporter), 'text'); rAfter(); }); });