From 7da022ebb4f6196f4ac07f7feffbfe9a430cd17b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 25 May 2014 15:39:54 -0700 Subject: [PATCH] Consistent test order. --- test/test.js | 196 +++++++++++++++++++++++++-------------------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/test/test.js b/test/test.js index d6bc0e3a3..b8c6d5aa9 100644 --- a/test/test.js +++ b/test/test.js @@ -2779,6 +2779,14 @@ deepEqual(actual, [1, 2]); }); + test('should work with an object for `callback`', 1, function() { + deepEqual(_.first(objects, { 'b': 2 }), objects.slice(0, 1)); + }); + + test('should work with a string for `callback`', 1, function() { + deepEqual(_.first(objects, 'b'), objects.slice(0, 2)); + }); + test('should chain when passing `n`, `callback`, or `thisArg`', 3, function() { if (!isNpm) { var actual = _(array).first(2); @@ -2812,14 +2820,6 @@ } }); - test('should work with an object for `callback`', 1, function() { - deepEqual(_.first(objects, { 'b': 2 }), objects.slice(0, 1)); - }); - - test('should work with a string for `callback`', 1, function() { - deepEqual(_.first(objects, 'b'), objects.slice(0, 2)); - }); - test('should be aliased', 2, function() { strictEqual(_.head, _.first); strictEqual(_.take, _.first); @@ -3275,16 +3275,6 @@ strictEqual(func(), undefined); }); - test('`_.' + methodName + '` should return the existing wrapper when chaining', 1, function() { - if (!isNpm) { - var wrapper = _({ 'a': 1 }); - strictEqual(wrapper[methodName]({ 'b': 2 }), wrapper); - } - else { - skipTest(); - } - }); - test('`_.' + methodName + '` should assign problem JScript properties (test in IE < 9)', 1, function() { var object = { 'constructor': '0', @@ -3345,6 +3335,16 @@ deepEqual(actual, expected); }); + + test('`_.' + methodName + '` should return the existing wrapper when chaining', 1, function() { + if (!isNpm) { + var wrapper = _({ 'a': 1 }); + strictEqual(wrapper[methodName]({ 'b': 2 }), wrapper); + } + else { + skipTest(); + } + }); }); _.each(['assign', 'merge'], function(methodName) { @@ -3915,6 +3915,13 @@ deepEqual(_.intersection(_.range(largeArraySize), null, [1]), [1]); }); + test('should ignore values that are not arrays or `arguments` objects', 3, function() { + var array = [0, 1, null, 3]; + deepEqual(_.intersection(array, 3, null, { '0': 1 }), array); + deepEqual(_.intersection(null, array, null, [2, 1]), [1]); + deepEqual(_.intersection(null, array, null, args), [1, 3]); + }); + test('should return a wrapped value when chaining', 2, function() { if (!isNpm) { var actual = _([1, 3, 2]).intersection([5, 2, 1, 4]); @@ -3925,13 +3932,6 @@ skipTest(2); } }); - - test('should ignore values that are not arrays or `arguments` objects', 3, function() { - var array = [0, 1, null, 3]; - deepEqual(_.intersection(array, 3, null, { '0': 1 }), array); - deepEqual(_.intersection(null, array, null, [2, 1]), [1]); - deepEqual(_.intersection(null, array, null, args), [1, 3]); - }); }(1, 2, 3)); /*--------------------------------------------------------------------------*/ @@ -4779,24 +4779,6 @@ } }); - test('should return an unwrapped value when intuitively chaining', 1, function() { - if (!isNpm) { - strictEqual(_('a').isEqual('a'), true); - } - else { - skipTest(); - } - }); - - test('should return a wrapped value when explicitly chaining', 1, function() { - if (!isNpm) { - ok(_('a').chain().isEqual('a') instanceof _); - } - else { - skipTest(); - } - }); - test('should perform comparisons between wrapped values', 4, function() { if (!isNpm) { var object1 = _({ 'a': 1, 'b': 2 }), @@ -4863,6 +4845,24 @@ skipTest(); } }); + + test('should return an unwrapped value when intuitively chaining', 1, function() { + if (!isNpm) { + strictEqual(_('a').isEqual('a'), true); + } + else { + skipTest(); + } + }); + + test('should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_('a').chain().isEqual('a') instanceof _); + } + else { + skipTest(); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -5700,6 +5700,14 @@ deepEqual(actual, [2, 3]); }); + test('should work with an object for `callback`', 1, function() { + deepEqual(_.last(objects, { 'b': 2 }), objects.slice(-1)); + }); + + test('should work with a string for `callback`', 1, function() { + deepEqual(_.last(objects, 'b'), objects.slice(-2)); + }); + test('should chain when passing `n`, `callback`, or `thisArg`', 3, function() { if (!isNpm) { var actual = _(array).last(2); @@ -5732,14 +5740,6 @@ skipTest(); } }); - - test('should work with an object for `callback`', 1, function() { - deepEqual(_.last(objects, { 'b': 2 }), objects.slice(-1)); - }); - - test('should work with a string for `callback`', 1, function() { - deepEqual(_.last(objects, 'b'), objects.slice(-2)); - }); }()); /*--------------------------------------------------------------------------*/ @@ -5871,15 +5871,6 @@ } }); - test('should return a wrapped value when chaining', 1, function() { - if (!isNpm) { - ok(_(array).map(_.noop) instanceof _); - } - else { - skipTest(); - } - }); - test('should treat a nodelist as an array-like object', 1, function() { if (document) { var actual = _.map(document.getElementsByTagName('body'), function(element) { @@ -5909,6 +5900,15 @@ deepEqual(_.map(1), []); }); + test('should return a wrapped value when chaining', 1, function() { + if (!isNpm) { + ok(_(array).map(_.noop) instanceof _); + } + else { + skipTest(); + } + }); + test('should be aliased', 1, function() { strictEqual(_.collect, _.map); }); @@ -5956,15 +5956,6 @@ deepEqual(actual, object); }); - test('should return a wrapped value when chaining', 1, function() { - if (!isNpm) { - ok(_(object).mapValues(_.noop) instanceof _); - } - else { - skipTest(); - } - }); - test('should accept a falsey `object` argument', 1, function() { var expected = _.map(falsey, _.constant({})); @@ -5976,6 +5967,15 @@ deepEqual(actual, expected); }); + + test('should return a wrapped value when chaining', 1, function() { + if (!isNpm) { + ok(_(object).mapValues(_.noop) instanceof _); + } + else { + skipTest(); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -6386,6 +6386,11 @@ strictEqual(actual, object); }); + test('`_.' + methodName + '` should work with extremely large arrays', 1, function() { + var array = _.range(0, 5e5); + strictEqual(func(array), isMax ? 499999 : 0); + }); + test('`_.' + methodName + '` should work when chaining on an array with only one value', 1, function() { if (!isNpm) { var actual = _([40])[methodName]().value(); @@ -6395,11 +6400,6 @@ skipTest(); } }); - - test('`_.' + methodName + '` should work with extremely large arrays', 1, function() { - var array = _.range(0, 5e5); - strictEqual(func(array), isMax ? 499999 : 0); - }); }); /*--------------------------------------------------------------------------*/ @@ -7674,19 +7674,6 @@ deepEqual(actual, 6); }); - test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() { - if (!isNpm) { - var actual = _(array)[methodName](function(sum, num) { - return sum + num; - }); - - strictEqual(actual, 6); - } - else { - skipTest(); - } - }); - test('`_.' + methodName + '` should support empty or falsey collections without an initial `accumulator` value', 1, function() { var actual = [], expected = _.map(empties, _.constant()); @@ -7730,6 +7717,19 @@ } strictEqual(_.reduce(object, _.noop), undefined); }); + + test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() { + if (!isNpm) { + var actual = _(array)[methodName](function(sum, num) { + return sum + num; + }); + + strictEqual(actual, 6); + } + else { + skipTest(); + } + }); }); /*--------------------------------------------------------------------------*/ @@ -10102,17 +10102,6 @@ notStrictEqual(_.xor(array), array); }); - test('should return a wrapped value when chaining', 2, function() { - if (!isNpm) { - var actual = _([1, 2, 3]).xor([5, 2, 1, 4]); - ok(actual instanceof _); - deepEqual(actual.value(), [3, 5, 4]); - } - else { - skipTest(2); - } - }); - test('should ignore individual secondary arguments', 1, function() { var array = [0]; deepEqual(_.xor(array, 3, null, { '0': 1 }), array); @@ -10124,6 +10113,17 @@ deepEqual(_.xor(null, array, null, [2, 3]), [1, 3]); deepEqual(_.xor(null, array, null, args), [3]); }); + + test('should return a wrapped value when chaining', 2, function() { + if (!isNpm) { + var actual = _([1, 2, 3]).xor([5, 2, 1, 4]); + ok(actual instanceof _); + deepEqual(actual.value(), [3, 5, 4]); + } + else { + skipTest(2); + } + }); }(1, 2, 3)); /*--------------------------------------------------------------------------*/