From 404edebdff6c63e45585ea90719ea4e4740f0ed5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 5 Jul 2014 07:39:31 -0500 Subject: [PATCH] Cleanup unwrapped chaining tests and add a chaining test for `_.attempt`. --- test/test.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/test/test.js b/test/test.js index 90402489f..fda4367b2 100644 --- a/test/test.js +++ b/test/test.js @@ -775,6 +775,15 @@ skipTest(); } }); + + test('should return an unwrapped value when chaining', 1, function() { + if (!isNpm) { + strictEqual(_(_.constant('x')).attempt(), 'x'); + } + else { + skipTest(); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -1164,8 +1173,7 @@ test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() { if (!isNpm) { - var actual = _('hello world')[methodName](); - strictEqual(actual, expected); + strictEqual(_('hello world')[methodName](), expected); } else { skipTest(); @@ -1204,8 +1212,7 @@ test('should return an unwrapped value when chaining', 1, function() { if (!isNpm) { - var actual = _('fred').capitalize(); - strictEqual(actual, 'Fred'); + strictEqual(_('fred').capitalize(), 'Fred'); } else { skipTest(); @@ -9342,7 +9349,7 @@ } }); - test('should return intercept unwrapped values and return wrapped values when chaining', 2, function() { + test('should intercept unwrapped values and return wrapped values when chaining', 2, function() { if (!isNpm) { var intercepted, array = [1, 2, 3]; @@ -10398,10 +10405,9 @@ test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() { if (!isNpm) { var string = whitespace + 'a b c' + whitespace, - expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''), - actual = _(string)[methodName](); + expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''); - strictEqual(actual, expected); + strictEqual(_(string)[methodName](), expected); } else { skipTest(); @@ -11159,10 +11165,7 @@ _.each(funcs, function(methodName) { test('`_(...).' + methodName + '` should return an unwrapped value', 1, function() { if (!isNpm) { - var actual = methodName == 'reduceRight' - ? wrapped[methodName](_.identity) - : wrapped[methodName](); - + var actual = wrapped[methodName](); ok(!(actual instanceof _)); } else { @@ -11187,7 +11190,8 @@ _.each(funcs, function(methodName) { test('`_(...).' + methodName + '` called without an `n` argument should return an unwrapped value', 1, function() { if (!isNpm) { - strictEqual(typeof wrapped[methodName](), 'number'); + var actual = wrapped[methodName](); + strictEqual(typeof actual, 'number'); } else { skipTest();