Skip to content

Commit

Permalink
fix coverage in noHighlighting function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mia-jeong committed Oct 15, 2019
1 parent dbf0e4e commit 7770b95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,9 @@ Mocha.prototype.noHighlighting = function(enableHighlight) {
utils.deprecate(
'noHighlighting is deprecated; provide {reporterOption: {highlight: false}} to mocha.setup().'
);
enableHighlight = enableHighlight === undefined ? true : enableHighlight;
this.options.reporterOptions = this.options.reporterOptions || {};
this.options.reporterOptions.highlight = enableHighlight !== true;
this.options.reporterOptions.highlight =
enableHighlight !== undefined && enableHighlight !== true;
return this;
};

Expand Down
22 changes: 22 additions & 0 deletions test/unit/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,28 @@ describe('Mocha', function() {
);
});

it('should set the reporterOptions.highlight to false', function() {
var mocha = new Mocha(opts);
mocha.noHighlighting(true);
expect(
mocha.options.reporterOptions,
'to have property',
'highlight',
false
);
});

it('should set the reporterOptions.highlight to true', function() {
var mocha = new Mocha(opts);
mocha.noHighlighting(false);
expect(
mocha.options.reporterOptions,
'to have property',
'highlight',
true
);
});

it('should be chainable', function() {
var mocha = new Mocha(opts);
expect(mocha.noHighlighting(), 'to be', mocha);
Expand Down

0 comments on commit 7770b95

Please sign in to comment.