Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added colorized attribute to Printer as configuration variable

  • Loading branch information...
commit fb67d738538fee4018bef52c1b3cecd2de4904e7 1 parent 78818fe
Luke Bayes authored
Showing with 22 additions and 21 deletions.
  1. +21 −4 src/node_should/printer.js
  2. +1 −17 test/fake_printer.js
25 src/node_should/printer.js
View
@@ -2,6 +2,7 @@ var sys = require('sys');
var style = require('node_should/colored');
var Printer = function() {
+ this.colorized = true;
this.contexts = [];
this.errored = [];
this.failed = [];
@@ -76,19 +77,35 @@ Printer.prototype._printInfo = function(message) {
}
Printer.prototype._printSuccess = function(message) {
- this.out.write(style.green(message));
+ if (this.colorized) {
+ this._printInfo(style.green(message));
+ } else {
+ this._printInfo(message);
+ }
}
Printer.prototype._printFailure = function(message) {
- this.out.write(style.red(message));
+ if (this.colorized) {
+ this.out.write(style.red(message));
+ } else {
+ this._printInfo(message);
+ }
}
Printer.prototype._printError = function(message) {
- this.out.write(style.red(message));
+ if (this.colorized) {
+ this.out.write(style.red(message));
+ } else {
+ this._printInfo(message);
+ }
}
Printer.prototype._printIgnore = function(message) {
- this.out.write(style.yellow(message));
+ if (this.colorized) {
+ this.out.write(style.yellow(message));
+ } else {
+ this._printInfo(message);
+ }
}
Printer.prototype._addSuccess = function(test) {
18 test/fake_printer.js
View
@@ -10,26 +10,10 @@ var FakeStream = require('fake_stream').FakeStream;
var FakePrinter = function() {
Printer.call(this);
this.out = new FakeStream();
+ this.colorized = false;
}
util.inherits(FakePrinter, Printer);
-// Override colorized methods so that our tests can be a little simpler.
-FakePrinter.prototype._printSuccess = function(message) {
- this.out.write(message);
-}
-
-FakePrinter.prototype._printFailure = function(message) {
- this.out.write(message);
-}
-
-FakePrinter.prototype._printError = function(message) {
- this.out.write(message);
-}
-
-FakePrinter.prototype._printIgnore = function(message) {
- this.out.write(message);
-}
-
exports.FakePrinter = FakePrinter;
Please sign in to comment.
Something went wrong with that request. Please try again.