Skip to content
Browse files

Fix bug in negative threshold processing, add unit tests for same case

  • Loading branch information...
1 parent cc74095 commit 0198a87b2dee8dd7233652a14d6600cff0d780a1 @gotwarlost committed Jan 3, 2013
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/command/check-coverage.js
  2. +11 −0 test/cli/test-check-coverage-command.js
View
2 lib/command/check-coverage.js
@@ -96,7 +96,7 @@ Command.mix(CheckCoverageCommand, {
threshold = thresholds[key];
if (threshold < 0) {
- if (threshold * -1 > actualUncovered) {
+ if (threshold * -1 < actualUncovered) {
errors.push('ERROR: Uncovered count for ' + key + ' (' + actualUncovered + ') exceeds threshold (' + -1 * threshold + ')');
}
} else {
View
11 test/cli/test-check-coverage-command.js
@@ -68,6 +68,17 @@ module.exports = {
test.done();
});
},
+ "should fail with multiple reasons when multiple thresholds violated with negative thresholds": function (test) {
+ test.ok(existsSync(path.resolve(OUTPUT_DIR, 'coverage.json')));
+ run([ '--statements=-3', '--functions=-10', '--branches=-1', '--lines=-3' ], function (results) {
+ test.ok(!results.succeeded());
+ test.ok(results.grepError(/Uncovered count for lines/));
+ test.ok(results.grepError(/Uncovered count for statements/));
+ test.ok(results.grepError(/Uncovered count for branches/));
+ test.ok(!results.grepError(/Uncovered count for functions/));
+ test.done();
+ });
+ },
"should pass with multiple reasons when all thresholds in check": function (test) {
test.ok(existsSync(path.resolve(OUTPUT_DIR, 'coverage.json')));
run([ '--statements=60', '--functions=50', '--branches=50', '--lines=60', '-v' ], function (results) {

0 comments on commit 0198a87

Please sign in to comment.
Something went wrong with that request. Please try again.