diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index ed99a3e257..d34741e38a 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -18,36 +18,10 @@ describe('Mocha', function() { describe('constructor', function() { beforeEach(function() { - sandbox.stub(Mocha.prototype, 'useColors').returnsThis(); - sandbox.stub(utils, 'deprecate'); sandbox.stub(Mocha.prototype, 'timeout').returnsThis(); sandbox.stub(Mocha.prototype, 'globals').returnsThis(); }); - describe('when "useColors" option is defined', function() { - it('should prefer "color" over "useColors"', function() { - // eslint-disable-next-line no-new - new Mocha({useColors: true, color: false}); - expect(Mocha.prototype.useColors, 'to have a call satisfying', [ - false - ]).and('was called once'); - }); - - it('should assign "useColors" to "color"', function() { - // eslint-disable-next-line no-new - new Mocha({useColors: true}); - expect(Mocha.prototype.useColors, 'to have a call satisfying', [ - true - ]).and('was called once'); - }); - - it('should call utils.deprecate()', function() { - // eslint-disable-next-line no-new - new Mocha({useColors: true}); - expect(utils.deprecate, 'was called once'); - }); - }); - describe('when "timeout" option is `undefined`', function() { it('should not attempt to set timeout', function() { // eslint-disable-next-line no-new @@ -74,34 +48,6 @@ describe('Mocha', function() { ['singular'] ]).and('was called once'); }); - it('should delete mocha.options.global', function() { - var mocha = new Mocha({global: ['singular']}); - expect(mocha.options.global, 'to be', undefined); - }); - }); - - describe('when "options.globals" is provided', function() { - it('should pass "options.globals" to #globals()', function() { - // eslint-disable-next-line no-new - new Mocha({globals: ['plural']}); - expect(Mocha.prototype.globals, 'to have a call satisfying', [ - ['plural'] - ]).and('was called once'); - }); - }); - - describe('when "options.global" AND "options.globals" are provided', function() { - it('should pass "options.global" to #globals(), ignoring "options.globals"', function() { - // eslint-disable-next-line no-new - new Mocha({global: ['singular'], globals: ['plural']}); - expect(Mocha.prototype.globals, 'to have a call satisfying', [ - ['singular'] - ]).and('was called once'); - }); - it('should delete mocha.options.global', function() { - var mocha = new Mocha({global: ['singular'], globals: ['plural']}); - expect(mocha.options.global, 'to be', undefined); - }); }); }); @@ -132,10 +78,10 @@ describe('Mocha', function() { }); describe('#checkLeaks()', function() { - it('should set the ignoreLeaks option to false', function() { + it('should set the checkLeaks option to true', function() { var mocha = new Mocha(opts); mocha.checkLeaks(); - expect(mocha.options, 'to have property', 'ignoreLeaks', false); + expect(mocha.options, 'to have property', 'checkLeaks', true); }); it('should be chainable', function() { @@ -158,10 +104,10 @@ describe('Mocha', function() { }); describe('#fullTrace()', function() { - it('should set the fullStackTrace option to true', function() { + it('should set the fullTrace option to true', function() { var mocha = new Mocha(opts); mocha.fullTrace(); - expect(mocha.options, 'to have property', 'fullStackTrace', true); + expect(mocha.options, 'to have property', 'fullTrace', true); }); it('should be chainable', function() { @@ -173,7 +119,7 @@ describe('Mocha', function() { describe('#globals()', function() { it('should be an empty array initially', function() { var mocha = new Mocha(); - expect(mocha.options.globals, 'to be empty'); + expect(mocha.options.global, 'to be empty'); }); it('should be chainable', function() { @@ -185,13 +131,13 @@ describe('Mocha', function() { it('should not modify the whitelist when given empty string', function() { var mocha = new Mocha(opts); mocha.globals(''); - expect(mocha.options.globals, 'to be empty'); + expect(mocha.options.global, 'to be empty'); }); it('should not modify the whitelist when given empty array', function() { var mocha = new Mocha(opts); mocha.globals([]); - expect(mocha.options.globals, 'to be empty'); + expect(mocha.options.global, 'to be empty'); }); }); @@ -203,24 +149,24 @@ describe('Mocha', function() { it('should add string to the whitelist', function() { var mocha = new Mocha(opts); mocha.globals(elem); - expect(mocha.options.globals, 'to contain', elem); - expect(mocha.options.globals, 'to have length', 1); + expect(mocha.options.global, 'to contain', elem); + expect(mocha.options.global, 'to have length', 1); }); it('should add contents of string array to the whitelist', function() { var mocha = new Mocha(opts); var elems = [elem, elem2]; mocha.globals(elems); - expect(mocha.options.globals, 'to contain', elem, elem2); - expect(mocha.options.globals, 'to have length', elems.length); + expect(mocha.options.global, 'to contain', elem, elem2); + expect(mocha.options.global, 'to have length', elems.length); }); it('should not have duplicates', function() { var mocha = new Mocha({globals: [elem, elem2]}); var elems = [elem, elem2, elem3]; mocha.globals(elems); - expect(mocha.options.globals, 'to contain', elem, elem2, elem3); - expect(mocha.options.globals, 'to have length', elems.length); + expect(mocha.options.global, 'to contain', elem, elem2, elem3); + expect(mocha.options.global, 'to have length', elems.length); }); }); }); @@ -255,22 +201,22 @@ describe('Mocha', function() { }); describe('#ignoreLeaks()', function() { - it('should set the ignoreLeaks option to true when param equals true', function() { + it('should set the checkLeaks option to false when param equals true', function() { var mocha = new Mocha(opts); mocha.ignoreLeaks(true); - expect(mocha.options, 'to have property', 'ignoreLeaks', true); + expect(mocha.options, 'to have property', 'checkLeaks', false); }); - it('should set the ignoreLeaks option to false when param equals false', function() { + it('should set the checkLeaks option to true when param equals false', function() { var mocha = new Mocha(opts); mocha.ignoreLeaks(false); - expect(mocha.options, 'to have property', 'ignoreLeaks', false); + expect(mocha.options, 'to have property', 'checkLeaks', true); }); - it('should set the ignoreLeaks option to false when the param is undefined', function() { + it('should set the checkLeaks option to true when the param is undefined', function() { var mocha = new Mocha(opts); mocha.ignoreLeaks(); - expect(mocha.options, 'to have property', 'ignoreLeaks', false); + expect(mocha.options, 'to have property', 'checkLeaks', true); }); it('should be chainable', function() { @@ -358,22 +304,22 @@ describe('Mocha', function() { }); describe('#useInlineDiffs()', function() { - it('should set the useInlineDiffs option to true when param equals true', function() { + it('should set the inlineDiffs option to true when param equals true', function() { var mocha = new Mocha(opts); mocha.useInlineDiffs(true); - expect(mocha.options, 'to have property', 'useInlineDiffs', true); + expect(mocha.options, 'to have property', 'inlineDiffs', true); }); - it('should set the useInlineDiffs option to false when param equals false', function() { + it('should set the inlineDiffs option to false when param equals false', function() { var mocha = new Mocha(opts); mocha.useInlineDiffs(false); - expect(mocha.options, 'to have property', 'useInlineDiffs', false); + expect(mocha.options, 'to have property', 'inlineDiffs', false); }); - it('should set the useInlineDiffs option to false when the param is undefined', function() { + it('should set the inlineDiffs option to false when the param is undefined', function() { var mocha = new Mocha(opts); mocha.useInlineDiffs(); - expect(mocha.options, 'to have property', 'useInlineDiffs', false); + expect(mocha.options, 'to have property', 'inlineDiffs', false); }); it('should be chainable', function() { diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.js index ec2b8a0f34..31ac938b1f 100644 --- a/test/unit/runner.spec.js +++ b/test/unit/runner.spec.js @@ -23,6 +23,7 @@ describe('Runner', function() { beforeEach(function() { suite = new Suite('Suite', 'root'); runner = new Runner(suite); + runner.checkLeaks = true; sandbox = sinon.createSandbox(); });