Skip to content

Commit

Permalink
fix unicode chars on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jsalonen authored and tj committed Nov 7, 2012
1 parent 0741ac4 commit bec7a6e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
21 changes: 19 additions & 2 deletions lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ exports.colors = {
, 'diff removed': 41
};

/**
* Default symbol map.
*/

exports.symbols = {
ok: '✔',
err: '✖',
dot: '․'
};

// With node.js on Windows: use symbols available in terminal default fonts
if (process && 'win32' == process.platform) {
exports.symbols.ok = '\u221A';
exports.symbols.err = '\u00D7';
exports.symbols.dot = '.';
}

/**
* Color `str` with the given `type`,
* allowing colors to be disabled,
Expand Down Expand Up @@ -277,7 +294,7 @@ Base.prototype.epilogue = function(){

// failure
if (stats.failures) {
fmt = color('bright fail', ' ✖')
fmt = color('bright fail', ' ' + exports.symbols.err)
+ color('fail', ' %d of %d %s failed')
+ color('light', ':')

Expand All @@ -292,7 +309,7 @@ Base.prototype.epilogue = function(){
}

// pass
fmt = color('bright pass', ' ✔')
fmt = color('bright pass', ' ' + exports.symbols.ok)
+ color('green', ' %d %s complete')
+ color('light', ' (%s)');

Expand Down
9 changes: 4 additions & 5 deletions lib/reporters/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,28 @@ function Dot(runner) {
var self = this
, stats = this.stats
, width = Base.window.width * .75 | 0
, c = '․'
, n = 0;

runner.on('start', function(){
process.stdout.write('\n ');
});

runner.on('pending', function(test){
process.stdout.write(color('pending', c));
process.stdout.write(color('pending', Base.symbols.dot));
});

runner.on('pass', function(test){
if (++n % width == 0) process.stdout.write('\n ');
if ('slow' == test.speed) {
process.stdout.write(color('bright yellow', c));
process.stdout.write(color('bright yellow', Base.symbols.dot));
} else {
process.stdout.write(color(test.speed, c));
process.stdout.write(color(test.speed, Base.symbols.dot));
}
});

runner.on('fail', function(test, err){
if (++n % width == 0) process.stdout.write('\n ');
process.stdout.write(color('fail', c));
process.stdout.write(color('fail', Base.symbols.dot));
});

runner.on('end', function(){
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function List(runner) {
});

runner.on('pass', function(test){
var fmt = color('checkmark', ' ✓')
var fmt = color('checkmark', ' '+Base.symbols.dot)
+ color('pass', ' %s: ')
+ color(test.speed, '%dms');
cursor.CR();
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Progress(runner, options) {
// default chars
options.open = options.open || '[';
options.complete = options.complete || '▬';
options.incomplete = options.incomplete || '⋅';
options.incomplete = options.incomplete || Base.symbols.dot;
options.close = options.close || ']';
options.verbose = false;

Expand Down
4 changes: 2 additions & 2 deletions lib/reporters/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ function Spec(runner) {
runner.on('pass', function(test){
if ('fast' == test.speed) {
var fmt = indent()
+ color('checkmark', ' ✓')
+ color('checkmark', ' ' + Base.symbols.ok)
+ color('pass', ' %s ');
cursor.CR();
console.log(fmt, test.title);
} else {
var fmt = indent()
+ color('checkmark', ' ✓')
+ color('checkmark', ' ' + Base.symbols.ok)
+ color('pass', ' %s ')
+ color(test.speed, '(%dms)');
cursor.CR();
Expand Down

0 comments on commit bec7a6e

Please sign in to comment.