From d9aa813974b3871ccb8832a7dcf3090a98df18e6 Mon Sep 17 00:00:00 2001 From: abetomo Date: Tue, 12 Sep 2017 18:57:54 +0900 Subject: [PATCH 1/4] Remove unnecessary line feeds --- lib/chai/core/assertions.js | 3 --- lib/chai/interface/assert.js | 2 -- lib/chai/utils/inspect.js | 4 ---- test/assert.js | 5 ----- test/configuration.js | 1 - test/should.js | 1 - 6 files changed, 16 deletions(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index d807b04d6..7ab254a4e 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -210,7 +210,6 @@ module.exports = function (chai, _) { flag(this, 'all', false); }); - /** * ### .all * @@ -2271,7 +2270,6 @@ module.exports = function (chai, _) { if (keysType !== 'Array') { keys = Array.prototype.slice.call(arguments); } - } else { actual = _.getOwnEnumerableProperties(obj); @@ -3078,7 +3076,6 @@ module.exports = function (chai, _) { Assertion.addMethod('oneOf', oneOf); - /** * ### .change(subject[, prop[, msg]]) * diff --git a/lib/chai/interface/assert.js b/lib/chai/interface/assert.js index fa7719157..59e5f8b66 100644 --- a/lib/chai/interface/assert.js +++ b/lib/chai/interface/assert.js @@ -4,9 +4,7 @@ * MIT Licensed */ - module.exports = function (chai, util) { - /*! * Chai dependencies. */ diff --git a/lib/chai/utils/inspect.js b/lib/chai/utils/inspect.js index 3cf5dcef6..186f8ea47 100644 --- a/lib/chai/utils/inspect.js +++ b/lib/chai/utils/inspect.js @@ -196,7 +196,6 @@ function formatValue(ctx, value, recurseTimes) { return reduceToSingleString(output, base, braces); } - function formatPrimitive(ctx, value) { switch (typeof value) { case 'undefined': @@ -226,12 +225,10 @@ function formatPrimitive(ctx, value) { } } - function formatError(value) { return '[' + Error.prototype.toString.call(value) + ']'; } - function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { var output = []; for (var i = 0, l = value.length; i < l; ++i) { @@ -334,7 +331,6 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { return name + ': ' + str; } - function reduceToSingleString(output, base, braces) { var numLinesEst = 0; var length = output.reduce(function(prev, cur) { diff --git a/test/assert.js b/test/assert.js index e3483ee97..3282fd1dd 100644 --- a/test/assert.js +++ b/test/assert.js @@ -130,7 +130,6 @@ describe('assert', function () { err(function () { assert.typeOf(5, 'string', 'blah'); }, "blah: expected 5 to be a string"); - }); it('notTypeOf', function () { @@ -242,7 +241,6 @@ describe('assert', function () { assert.notInstanceOf(new Foo(), undefined); }, "The instanceof assertion needs a constructor but undefined was given."); - if (typeof Symbol !== 'undefined' && typeof Symbol.hasInstance !== 'undefined') { err(function(){ assert.notInstanceOf(new Foo(), Symbol()); @@ -1769,8 +1767,6 @@ describe('assert', function () { err(function () { assert.operator(w, '===', null); }, "expected undefined to be === null"); - - }); it('closeTo', function(){ @@ -2043,7 +2039,6 @@ describe('assert', function () { err(function() { assert.oneOf({ four: 4 }, [1, 2, { four: 4 }]); }, 'expected { four: 4 } to be one of [ 1, 2, { four: 4 } ]'); - }); it('above', function() { diff --git a/test/configuration.js b/test/configuration.js index d53f164fc..d37c9ffa9 100644 --- a/test/configuration.js +++ b/test/configuration.js @@ -810,5 +810,4 @@ describe('configuration', function () { } }); }); - }); diff --git a/test/should.js b/test/should.js index 1453512d6..ec3b947d9 100644 --- a/test/should.js +++ b/test/should.js @@ -2054,7 +2054,6 @@ describe('should', function() { testSet.should.have.all.keys([{thisIs: 'anExampleObject'}, {doingThisBecauseOf: 'referential equality'}]); }); - // Using the same assertions as above but with `.deep` flag instead of using referential equality testSet.should.have.any.deep.keys({thisIs: 'anExampleObject'}); testSet.should.have.any.deep.keys('thisDoesNotExist', 'thisToo', {thisIs: 'anExampleObject'}); From 7d1e815f22dea0259bae8cfd4c50cc3b1ceddac2 Mon Sep 17 00:00:00 2001 From: abetomo Date: Tue, 12 Sep 2017 18:59:10 +0900 Subject: [PATCH 2/4] Remove unused variable declaration in utils/getMessage.js in core/assertions.js --- lib/chai/core/assertions.js | 2 +- lib/chai/utils/getMessage.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 7ab254a4e..4d2321abd 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -3004,7 +3004,7 @@ module.exports = function (chai, _) { var contains = flag(this, 'contains'); var ordered = flag(this, 'ordered'); - var subject, failMsg, failNegateMsg, lengthCheck; + var subject, failMsg, failNegateMsg; if (contains) { subject = ordered ? 'an ordered superset' : 'a superset'; diff --git a/lib/chai/utils/getMessage.js b/lib/chai/utils/getMessage.js index 1c9744feb..61e19b1c3 100644 --- a/lib/chai/utils/getMessage.js +++ b/lib/chai/utils/getMessage.js @@ -10,7 +10,6 @@ var flag = require('./flag') , getActual = require('./getActual') - , inspect = require('./inspect') , objDisplay = require('./objDisplay'); /** From 62baf22a44448b722ed47a4c234baf6e2894a4b1 Mon Sep 17 00:00:00 2001 From: abetomo Date: Tue, 12 Sep 2017 19:01:34 +0900 Subject: [PATCH 3/4] Fix string enclosed in single quotes in core/assertions.js In other code in this file, the string was enclosed in single quotes --- lib/chai/core/assertions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 4d2321abd..7b9090082 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -3723,7 +3723,7 @@ module.exports = function (chai, _) { var obj = flag(this, 'object'); this.assert( - typeof obj === "number" && isFinite(obj) + typeof obj === 'number' && isFinite(obj) , 'expected #{this} to be a finite number' , 'expected #{this} to not be a finite number' ); From 1c1b07490bafb61d15de6a084cee736f01c2c8a8 Mon Sep 17 00:00:00 2001 From: abetomo Date: Tue, 12 Sep 2017 19:03:14 +0900 Subject: [PATCH 4/4] Remove meaningless processing numLinesEst does not seem to be used anywhere after this. --- lib/chai/utils/inspect.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/chai/utils/inspect.js b/lib/chai/utils/inspect.js index 186f8ea47..205c52da0 100644 --- a/lib/chai/utils/inspect.js +++ b/lib/chai/utils/inspect.js @@ -332,10 +332,7 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { } function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; var length = output.reduce(function(prev, cur) { - numLinesEst++; - if (cur.indexOf('\n') >= 0) numLinesEst++; return prev + cur.length + 1; }, 0);