Skip to content

Commit 7770b95

Browse files
committed
fix coverage in noHighlighting function
1 parent dbf0e4e commit 7770b95

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/mocha.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,9 @@ Mocha.prototype.noHighlighting = function(enableHighlight) {
690690
utils.deprecate(
691691
'noHighlighting is deprecated; provide {reporterOption: {highlight: false}} to mocha.setup().'
692692
);
693-
enableHighlight = enableHighlight === undefined ? true : enableHighlight;
694693
this.options.reporterOptions = this.options.reporterOptions || {};
695-
this.options.reporterOptions.highlight = enableHighlight !== true;
694+
this.options.reporterOptions.highlight =
695+
enableHighlight !== undefined && enableHighlight !== true;
696696
return this;
697697
};
698698

test/unit/mocha.spec.js

+22
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,28 @@ describe('Mocha', function() {
300300
);
301301
});
302302

303+
it('should set the reporterOptions.highlight to false', function() {
304+
var mocha = new Mocha(opts);
305+
mocha.noHighlighting(true);
306+
expect(
307+
mocha.options.reporterOptions,
308+
'to have property',
309+
'highlight',
310+
false
311+
);
312+
});
313+
314+
it('should set the reporterOptions.highlight to true', function() {
315+
var mocha = new Mocha(opts);
316+
mocha.noHighlighting(false);
317+
expect(
318+
mocha.options.reporterOptions,
319+
'to have property',
320+
'highlight',
321+
true
322+
);
323+
});
324+
303325
it('should be chainable', function() {
304326
var mocha = new Mocha(opts);
305327
expect(mocha.noHighlighting(), 'to be', mocha);

0 commit comments

Comments
 (0)