Skip to content

Commit bec7a6e

Browse files
jsalonentj
authored andcommitted
fix unicode chars on windows
1 parent 0741ac4 commit bec7a6e

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

lib/reporters/base.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,23 @@ exports.colors = {
6161
, 'diff removed': 41
6262
};
6363

64+
/**
65+
* Default symbol map.
66+
*/
67+
68+
exports.symbols = {
69+
ok: '✔',
70+
err: '✖',
71+
dot: '․'
72+
};
73+
74+
// With node.js on Windows: use symbols available in terminal default fonts
75+
if (process && 'win32' == process.platform) {
76+
exports.symbols.ok = '\u221A';
77+
exports.symbols.err = '\u00D7';
78+
exports.symbols.dot = '.';
79+
}
80+
6481
/**
6582
* Color `str` with the given `type`,
6683
* allowing colors to be disabled,
@@ -277,7 +294,7 @@ Base.prototype.epilogue = function(){
277294

278295
// failure
279296
if (stats.failures) {
280-
fmt = color('bright fail', ' ✖')
297+
fmt = color('bright fail', ' ' + exports.symbols.err)
281298
+ color('fail', ' %d of %d %s failed')
282299
+ color('light', ':')
283300

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

294311
// pass
295-
fmt = color('bright pass', ' ✔')
312+
fmt = color('bright pass', ' ' + exports.symbols.ok)
296313
+ color('green', ' %d %s complete')
297314
+ color('light', ' (%s)');
298315

lib/reporters/dot.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,28 @@ function Dot(runner) {
2525
var self = this
2626
, stats = this.stats
2727
, width = Base.window.width * .75 | 0
28-
, c = '․'
2928
, n = 0;
3029

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

3534
runner.on('pending', function(test){
36-
process.stdout.write(color('pending', c));
35+
process.stdout.write(color('pending', Base.symbols.dot));
3736
});
3837

3938
runner.on('pass', function(test){
4039
if (++n % width == 0) process.stdout.write('\n ');
4140
if ('slow' == test.speed) {
42-
process.stdout.write(color('bright yellow', c));
41+
process.stdout.write(color('bright yellow', Base.symbols.dot));
4342
} else {
44-
process.stdout.write(color(test.speed, c));
43+
process.stdout.write(color(test.speed, Base.symbols.dot));
4544
}
4645
});
4746

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

5352
runner.on('end', function(){

lib/reporters/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function List(runner) {
4242
});
4343

4444
runner.on('pass', function(test){
45-
var fmt = color('checkmark', ' ✓')
45+
var fmt = color('checkmark', ' '+Base.symbols.dot)
4646
+ color('pass', ' %s: ')
4747
+ color(test.speed, '%dms');
4848
cursor.CR();

lib/reporters/progress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function Progress(runner, options) {
4141
// default chars
4242
options.open = options.open || '[';
4343
options.complete = options.complete || '▬';
44-
options.incomplete = options.incomplete || '⋅';
44+
options.incomplete = options.incomplete || Base.symbols.dot;
4545
options.close = options.close || ']';
4646
options.verbose = false;
4747

lib/reporters/spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ function Spec(runner) {
5858
runner.on('pass', function(test){
5959
if ('fast' == test.speed) {
6060
var fmt = indent()
61-
+ color('checkmark', ' ✓')
61+
+ color('checkmark', ' ' + Base.symbols.ok)
6262
+ color('pass', ' %s ');
6363
cursor.CR();
6464
console.log(fmt, test.title);
6565
} else {
6666
var fmt = indent()
67-
+ color('checkmark', ' ✓')
67+
+ color('checkmark', ' ' + Base.symbols.ok)
6868
+ color('pass', ' %s ')
6969
+ color(test.speed, '(%dms)');
7070
cursor.CR();

0 commit comments

Comments
 (0)