Skip to content

Commit

Permalink
test(unit/mocha.spec.js): Add missing chainable tests
Browse files Browse the repository at this point in the history
Migrated `Mocha#addFile` to "node-unit". Added missing chainable tests for `Mocha#allowUncaught`,
`Mocha#bail`, `Mocha#delay`, and `Mocha#noHighlighting`.
  • Loading branch information
plroebuck committed Feb 14, 2019
1 parent 43ec922 commit cbef1e3
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions test/unit/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('Mocha', function() {
sandbox.stub(Mocha.prototype, 'useColors').returnsThis();
sandbox.stub(utils, 'deprecate');
});

it('should prefer "color" over "useColors"', function() {
// eslint-disable-next-line no-new
new Mocha({useColors: true, color: false});
Expand Down Expand Up @@ -70,14 +71,6 @@ describe('Mocha', function() {
});
});

describe('.addFile()', function() {
it('should add the given file to the files array', function() {
var mocha = new Mocha(opts);
mocha.addFile('myFile.js');
expect(mocha.files, 'to have length', 1).and('to contain', 'myFile.js');
});
});

describe('.invert()', function() {
it('should set the invert option to true', function() {
var mocha = new Mocha(opts);
Expand Down Expand Up @@ -153,6 +146,7 @@ describe('Mocha', function() {
expect(mocha.options, 'to have property', 'growl', true);
});
});

describe('if not capable of notifications', function() {
it('should set the growl option to false', function() {
var mocha = new Mocha(opts);
Expand All @@ -163,6 +157,7 @@ describe('Mocha', function() {
expect(mocha.options, 'to have property', 'growl', false);
});
});

it('should be chainable', function() {
var mocha = new Mocha(opts);
expect(mocha.growl(), 'to be', mocha);
Expand Down Expand Up @@ -195,11 +190,17 @@ describe('Mocha', function() {
});

describe('.noHighlighting()', function() {
// :NOTE: Browser-only option...
it('should set the noHighlighting option to true', function() {
var mocha = new Mocha(opts);
mocha.noHighlighting();
expect(mocha.options, 'to have property', 'noHighlighting', true);
});

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

describe('.allowUncaught()', function() {
Expand All @@ -208,6 +209,11 @@ describe('Mocha', function() {
mocha.allowUncaught();
expect(mocha.options, 'to have property', 'allowUncaught', true);
});

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

describe('.delay()', function() {
Expand All @@ -216,6 +222,11 @@ describe('Mocha', function() {
mocha.delay();
expect(mocha.options, 'to have property', 'delay', true);
});

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

describe('.bail()', function() {
Expand All @@ -224,6 +235,11 @@ describe('Mocha', function() {
mocha.bail();
expect(mocha.suite._bail, 'to be', true);
});

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

describe('error handling', function() {
Expand Down

0 comments on commit cbef1e3

Please sign in to comment.