Skip to content

Commit 1b79ef5

Browse files
committed
Merge pull request #60 from bem/mocha-colors
Mocha colors
2 parents b62c92e + b67bf6d commit 1b79ef5

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

lib/cli.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ var path = require('path'),
88
module.exports = require('coa').Cmd()
99
.name(process.argv[1])
1010
.helpful()
11-
.title('Compares two html-files\n' +
12-
'Red text'.red + ' should be removed from the first html relative to the second one, ' +
13-
'green text'.green + ' should be added')
11+
.title('Compares two html-files')
1412
.opt()
1513
.name('version')
1614
.title('Shows the version number')

lib/diff-logger.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function getDiffText(diff, options) {
3535
if (part.removed) color = 'red';
3636

3737
if (color !== 'grey') {
38-
output += (!index ? '\n' : '') + partValue[color];
38+
output += (!index ? '\n' : '') + partValue.inverse[color];
3939

4040
return;
4141
}
@@ -63,7 +63,9 @@ function getDiffText(diff, options) {
6363
function log(diff, options) {
6464
var diffText = getDiffText(diff, options);
6565

66-
console.log(diffText);
66+
if (diffText) {
67+
console.log('+ expected'.inverse.green, '- actual'.inverse.red, '\n', diffText);
68+
}
6769
}
6870

6971
module.exports = {

test/getDiffText.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('\'diffHtml\'', function () {
3939
removed: undefined
4040
} ],
4141

42-
out = '\n...\n' + 'texttexttexttexttext'.grey + '!'.green + 'Text'.grey + '!'.green + 'texttexttexttext'.grey;
42+
out = '\n...\n' + 'texttexttexttexttext'.grey + '!'.inverse.green + 'Text'.grey + '!'.inverse.green + 'texttexttexttext'.grey;
4343

4444
diffLoger.getDiffText(inp).must.be.eql(out);
4545
});
@@ -68,7 +68,7 @@ describe('\'diffHtml\'', function () {
6868
removed: true
6969
} ],
7070

71-
out = '\n' + 'texttexttexttexttexttexttexttexttexttexttext'.green + 'ololoololoololoololoololoololoololoololoolol'.red;
71+
out = '\n' + 'texttexttexttexttexttexttexttexttexttexttext'.inverse.green + 'ololoololoololoololoololoololoololoololoolol'.inverse.red;
7272

7373
diffLoger.getDiffText(inp).must.be.eql(out);
7474
});
@@ -89,7 +89,7 @@ describe('\'diffHtml\'', function () {
8989
removed: undefined
9090
} ],
9191

92-
out = '\n' + 'texttexttext'.grey + 'text'.red + 'texttexttexttext'.grey;
92+
out = '\n' + 'texttexttext'.grey + 'text'.inverse.red + 'texttexttexttext'.grey;
9393

9494
diffLoger.getDiffText(inp).must.be.eql(out);
9595
});
@@ -126,7 +126,7 @@ describe('\'diffHtml\'', function () {
126126
removed: undefined
127127
} ],
128128

129-
out = '\n...\n' + 'texttexttexttexttext'.grey + 'text'.red + 'texttexttexttexttext'.grey + '\n...\n' + 'texttexttexttexttext'.grey + '!'.green + 'text'.grey + '!'.green + 'texttexttexttexttext'.grey;
129+
out = '\n...\n' + 'texttexttexttexttext'.grey + 'text'.inverse.red + 'texttexttexttexttext'.grey + '\n...\n' + 'texttexttexttexttext'.grey + '!'.inverse.green + 'text'.grey + '!'.inverse.green + 'texttexttexttexttext'.grey;
130130

131131
diffLoger.getDiffText(inp).must.be.eql(out);
132132
});

0 commit comments

Comments
 (0)