diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index d34741e38a..648853feab 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -20,9 +20,10 @@ 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}); @@ -30,7 +31,7 @@ describe('Mocha', function() { }); }); - 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}); @@ -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() { @@ -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); @@ -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); @@ -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);