Permalink
Browse files

nested reporter: fixing nodelint failures (with white set to false fo…

…r strict whitespace)
  • Loading branch information...
1 parent de9c0e3 commit 0125691a3e2ac7ddd3d2a3cc78641a79d5f1f700 @BryanDonovan BryanDonovan committed Oct 29, 2011
Showing with 24 additions and 19 deletions.
  1. +20 −18 lib/reporters/nested.js
  2. +4 −1 nodelint.cfg
@@ -34,7 +34,8 @@ exports.run = function (files, options) {
if (!options) {
// load default options
var content = fs.readFileSync(
- __dirname + '/../../bin/nodeunit.json', 'utf8'
+ __dirname + '/../../bin/nodeunit.json',
+ 'utf8'
);
options = JSON.parse(content);
}
@@ -57,13 +58,14 @@ exports.run = function (files, options) {
return path.join(process.cwd(), p);
});
var tracker = track.createTracker(function (tracker) {
+ var i, names;
if (tracker.unfinished()) {
console.log('');
console.log(error(bold(
'FAILURES: Undone tests (or their setups/teardowns): '
)));
- var names = tracker.names();
- for (var i = 0; i < names.length; i += 1) {
+ names = tracker.names();
+ for (i = 0; i < names.length; i += 1) {
console.log('- ' + names[i]);
}
console.log('');
@@ -76,15 +78,16 @@ exports.run = function (files, options) {
// i.e., whether this part has been printed yet.
tracker.already_printed = {};
- tracker.print_status = function(status, name_arr) {
+ tracker.print_status = function (status, name_arr) {
var txt = '';
var space = " ";
- for (var i = 0; i < name_arr.length; i++) {
- var part = name_arr.slice(0, i+1).join(",");
+ var part, i, k;
+ for (i = 0; i < name_arr.length; i++) {
+ part = name_arr.slice(0, i + 1).join(",");
// Only print the part if it hasn't already been printed.
if (!tracker.already_printed[part]) {
// Indent once for each nested level
- for (var k = 0; k < i; k++) {
+ for (k = 0; k < i; k++) {
txt += space;
}
if (i === name_arr.length - 1) {
@@ -95,7 +98,8 @@ exports.run = function (files, options) {
txt += bold(error(name_arr[i] + " (fail) ✖ "));
}
} else {
- // This is a testCase, just print the testCase name and a newline.
+ // This is a testCase, just print the testCase name
+ // and a newline.
txt += name_arr[i];
txt += "\n";
}
@@ -115,16 +119,15 @@ exports.run = function (files, options) {
if (!assertions.failures()) {
tracker.print_status('pass', name);
- }
- else {
+ } else {
tracker.print_status('fail', name);
assertions.forEach(function (a) {
if (a.failed()) {
a = utils.betterErrors(a);
if (a.error instanceof AssertionError && a.message) {
console.log(
'Assertion Message: ' +
- assertion_message(a.message)
+ assertion_message(a.message)
);
}
console.log(a.error.stack + '\n');
@@ -138,18 +141,17 @@ exports.run = function (files, options) {
if (assertions.failures()) {
console.log(
'\n' + bold(error('FAILURES: ')) + assertions.failures() +
- '/' + assertions.length + ' assertions failed (' +
- assertions.duration + 'ms)'
+ '/' + assertions.length + ' assertions failed (' +
+ assertions.duration + 'ms)'
);
- }
- else {
+ } else {
console.log(
- '\n' + bold(ok('OK: ')) + assertions.length +
- ' assertions (' + assertions.duration + 'ms)'
+ '\n' + bold(ok('OK: ')) + assertions.length +
+ ' assertions (' + assertions.duration + 'ms)'
);
}
},
- testStart: function(name) {
+ testStart: function (name) {
tracker.put(name);
}
});
View
@@ -1,4 +1,7 @@
+//See: http://www.jslint.com/lint.html#options
var options = {
+ //white: false, // if false, strict whitespace rules should be enforced.
indent: 4,
- onevar: false
+ onevar: false,
+ vars: true // allow multiple var statement per function.
};

0 comments on commit 0125691

Please sign in to comment.