Skip to content

Commit

Permalink
additional unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Aug 30, 2019
1 parent 263202e commit 897b917
Showing 1 changed file with 70 additions and 2 deletions.
72 changes: 70 additions & 2 deletions test/unit/mocha.spec.js
Expand Up @@ -20,17 +20,18 @@ describe('Mocha', function() {
beforeEach(function() {
sandbox.stub(Mocha.prototype, 'timeout').returnsThis();
sandbox.stub(Mocha.prototype, 'globals').returnsThis();
sandbox.stub(Mocha.prototype, 'useInlineDiffs').returnsThis();
});

describe('when "timeout" option is `undefined`', function() {
describe('when "options.timeout" is `undefined`', function() {
it('should not attempt to set timeout', function() {
// eslint-disable-next-line no-new
new Mocha({timeout: undefined});
expect(Mocha.prototype.timeout, 'was not called');
});
});

describe('when "timeout" option is `false`', function() {
describe('when "options.timeout" is `false`', function() {
it('should set a timeout of 0', function() {
// eslint-disable-next-line no-new
new Mocha({timeout: false});
Expand All @@ -49,6 +50,16 @@ describe('Mocha', function() {
]).and('was called once');
});
});

describe('when "options.inlineDiffs" is `undefined`', function() {
it('should set inlineDiffs to `true`', function() {
// eslint-disable-next-line no-new
new Mocha({inlineDiffs: true});
expect(Mocha.prototype.useInlineDiffs, 'to have a call satisfying', [
true
]).and('was called once');
});
});
});

describe('#allowUncaught()', function() {
Expand Down Expand Up @@ -103,6 +114,19 @@ describe('Mocha', function() {
});
});

describe('#enableTimeouts()', function() {
it('should set the suite._enableTimeouts to true if no argument', function() {
var mocha = new Mocha(opts);
mocha.enableTimeouts();
expect(mocha.suite._enableTimeouts, 'to be', true);
});

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

describe('#fullTrace()', function() {
it('should set the fullTrace option to true', function() {
var mocha = new Mocha(opts);
Expand Down Expand Up @@ -200,6 +224,31 @@ describe('Mocha', function() {
});
});

describe('#hideDiff()', function() {
it('should set the diff option to false when param equals true', function() {
var mocha = new Mocha(opts);
mocha.hideDiff(true);
expect(mocha.options, 'to have property', 'diff', false);
});

it('should set the diff option to true when param equals false', function() {
var mocha = new Mocha(opts);
mocha.hideDiff(false);
expect(mocha.options, 'to have property', 'diff', true);
});

it('should set the diff option to true when the param is undefined', function() {
var mocha = new Mocha(opts);
mocha.hideDiff();
expect(mocha.options, 'to have property', 'diff', true);
});

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

describe('#ignoreLeaks()', function() {
it('should set the checkLeaks option to false when param equals true', function() {
var mocha = new Mocha(opts);
Expand Down Expand Up @@ -303,6 +352,25 @@ describe('Mocha', function() {
});
});

describe('#useColors()', function() {
it('should set the color option to true', function() {
var mocha = new Mocha(opts);
mocha.useColors(true);
expect(mocha.options, 'to have property', 'color', true);
});

it('should not create the color property', function() {
var mocha = new Mocha(opts);
mocha.useColors();
expect(mocha.options, 'not to have property', 'color');
});

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

describe('#useInlineDiffs()', function() {
it('should set the inlineDiffs option to true when param equals true', function() {
var mocha = new Mocha(opts);
Expand Down

0 comments on commit 897b917

Please sign in to comment.