Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
CLI: correct tests for the "reporter" option
Browse files Browse the repository at this point in the history
Assertion for the "reporter" option actually didn't test anything
  • Loading branch information
markelog committed Jan 8, 2015
1 parent 6da56c1 commit 3fe2a92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module.exports = function(program) {
reporterPath = './reporters/' + (
program.colors && supportsColor ? 'console' : 'text'
);
returnArgs.reporter = reporterPath;
}

try {
Expand Down
24 changes: 15 additions & 9 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});

Expand Down Expand Up @@ -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();
});
});
Expand All @@ -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();
});
});
Expand All @@ -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();
});
});
Expand All @@ -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();
});
});
Expand Down

0 comments on commit 3fe2a92

Please sign in to comment.