From ebb7b48b76a5f07d653270ebc4a5401bc865765a Mon Sep 17 00:00:00 2001 From: Sebastian Van Sande Date: Tue, 7 Feb 2017 17:58:23 +0100 Subject: [PATCH 1/3] increase test coverage of mocha.js --- test/unit/mocha.spec.js | 130 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index af0c44a730..52437de528 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -32,4 +32,134 @@ describe('Mocha', function () { }); }); }); + + describe('.addFile()', function () { + it('should add the given file to the files array', function () { + var mocha = new Mocha(blankOpts); + mocha.addFile('myFile.js'); + mocha.files.length.should.equal(1); + mocha.files[0].should.equal('myFile.js'); + }); + }); + + describe('.invert()', function () { + it('should set the invert option to true', function () { + var mocha = new Mocha(blankOpts); + mocha.invert(); + mocha.options.invert.should.equal(true); + }); + + it('should be chainable', function () { + var mocha = new Mocha(blankOpts); + mocha.invert().should.equal(mocha); + }); + }); + + describe('.ignoreLeaks()', function () { + it('should set the ignoreLeaks option to true when param equals true', function () { + var mocha = new Mocha(blankOpts); + mocha.ignoreLeaks(true); + mocha.options.ignoreLeaks.should.equal(true); + }); + + it('should set the ignoreLeaks option to true when param equals false', function () { + var mocha = new Mocha(blankOpts); + mocha.ignoreLeaks(false); + mocha.options.ignoreLeaks.should.equal(false); + }); + + it('should be chainable', function () { + var mocha = new Mocha(blankOpts); + mocha.ignoreLeaks(false).should.equal(mocha); + }); + }); + + describe('.checkLeaks()', function () { + it('should set the ignoreLeaks option to false', function () { + var mocha = new Mocha(blankOpts); + mocha.checkLeaks(); + mocha.options.ignoreLeaks.should.equal(false); + }); + + it('should be chainable', function () { + var mocha = new Mocha(blankOpts); + mocha.checkLeaks().should.equal(mocha); + }); + }); + + describe('.fullTrace()', function () { + it('should set the fullStackTrace option to true', function () { + var mocha = new Mocha(blankOpts); + mocha.fullTrace(); + mocha.options.fullStackTrace.should.equal(true); + }); + + it('should be chainable', function () { + var mocha = new Mocha(blankOpts); + mocha.fullTrace().should.equal(mocha); + }); + }); + + describe('.growl()', function () { + it('should set the growl option to true', function () { + var mocha = new Mocha(blankOpts); + mocha.growl(); + mocha.options.growl.should.equal(true); + }); + + it('should be chainable', function () { + var mocha = new Mocha(blankOpts); + mocha.growl().should.equal(mocha); + }); + }); + + describe('.useInlineDiffs()', function () { + it('should set the useInlineDiffs option to true when param equals true', function () { + var mocha = new Mocha(blankOpts); + mocha.useInlineDiffs(true); + mocha.options.useInlineDiffs.should.equal(true); + }); + + it('should set the useInlineDiffs option to true when param equals false', function () { + var mocha = new Mocha(blankOpts); + mocha.useInlineDiffs(false); + mocha.options.useInlineDiffs.should.equal(false); + }); + + it('should set the useInlineDiffs option to false when the param is undefined', function () { + var mocha = new Mocha(blankOpts); + mocha.useInlineDiffs(); + mocha.options.useInlineDiffs.should.equal(false); + }); + + it('should be chainable', function () { + var mocha = new Mocha(blankOpts); + mocha.useInlineDiffs().should.equal(mocha); + }); + }); + + describe('.noHighlighting()', function () { + it('should set the noHighlighting option to true', function () { + var mocha = new Mocha(blankOpts); + mocha.noHighlighting(); + mocha.options.noHighlighting.should.equal(true); + }); + }); + + describe('.allowUncaught()', function () { + it('should set the allowUncaught option to true', function () { + var mocha = new Mocha(blankOpts); + mocha.allowUncaught(); + mocha.options.allowUncaught.should.equal(true); + }); + }); + + describe('.delay()', function () { + it('should set the delay option to true', function () { + var mocha = new Mocha(blankOpts); + mocha.delay(); + mocha.options.delay.should.equal(true); + }); + }); + }); From a763592308faa147f00579a94fb788627bcc0936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20M=C3=BCller?= Date: Tue, 7 Feb 2017 21:28:00 +0100 Subject: [PATCH 2/3] Linting --- test/unit/mocha.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index 52437de528..2de2fc4768 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -161,5 +161,4 @@ describe('Mocha', function () { mocha.options.delay.should.equal(true); }); }); - }); From 1b1377c4048e0b6de93a0b9b7aa9d568c7ef6fba Mon Sep 17 00:00:00 2001 From: Sebastian Van Sande Date: Thu, 15 Jun 2017 15:12:21 +0200 Subject: [PATCH 3/3] Add test for ignoreLeaks and fix descriptions --- test/unit/mocha.spec.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index 2de2fc4768..befb9302d4 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -62,12 +62,18 @@ describe('Mocha', function () { mocha.options.ignoreLeaks.should.equal(true); }); - it('should set the ignoreLeaks option to true when param equals false', function () { + it('should set the ignoreLeaks option to false when param equals false', function () { var mocha = new Mocha(blankOpts); mocha.ignoreLeaks(false); mocha.options.ignoreLeaks.should.equal(false); }); + it('should set the ignoreLeaks option to false when the param is undefined', function () { + var mocha = new Mocha(blankOpts); + mocha.ignoreLeaks(); + mocha.options.ignoreLeaks.should.equal(false); + }); + it('should be chainable', function () { var mocha = new Mocha(blankOpts); mocha.ignoreLeaks(false).should.equal(mocha); @@ -120,7 +126,7 @@ describe('Mocha', function () { mocha.options.useInlineDiffs.should.equal(true); }); - it('should set the useInlineDiffs option to true when param equals false', function () { + it('should set the useInlineDiffs option to false when param equals false', function () { var mocha = new Mocha(blankOpts); mocha.useInlineDiffs(false); mocha.options.useInlineDiffs.should.equal(false);