mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Cleanup unwrapped chaining tests and add a chaining test for _.attempt.
This commit is contained in:
30
test/test.js
30
test/test.js
@@ -775,6 +775,15 @@
|
|||||||
skipTest();
|
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() {
|
test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var actual = _('hello world')[methodName]();
|
strictEqual(_('hello world')[methodName](), expected);
|
||||||
strictEqual(actual, expected);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest();
|
skipTest();
|
||||||
@@ -1204,8 +1212,7 @@
|
|||||||
|
|
||||||
test('should return an unwrapped value when chaining', 1, function() {
|
test('should return an unwrapped value when chaining', 1, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var actual = _('fred').capitalize();
|
strictEqual(_('fred').capitalize(), 'Fred');
|
||||||
strictEqual(actual, 'Fred');
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest();
|
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) {
|
if (!isNpm) {
|
||||||
var intercepted,
|
var intercepted,
|
||||||
array = [1, 2, 3];
|
array = [1, 2, 3];
|
||||||
@@ -10398,10 +10405,9 @@
|
|||||||
test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() {
|
test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var string = whitespace + 'a b c' + whitespace,
|
var string = whitespace + 'a b c' + whitespace,
|
||||||
expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''),
|
expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : '');
|
||||||
actual = _(string)[methodName]();
|
|
||||||
|
|
||||||
strictEqual(actual, expected);
|
strictEqual(_(string)[methodName](), expected);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest();
|
skipTest();
|
||||||
@@ -11159,10 +11165,7 @@
|
|||||||
_.each(funcs, function(methodName) {
|
_.each(funcs, function(methodName) {
|
||||||
test('`_(...).' + methodName + '` should return an unwrapped value', 1, function() {
|
test('`_(...).' + methodName + '` should return an unwrapped value', 1, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var actual = methodName == 'reduceRight'
|
var actual = wrapped[methodName]();
|
||||||
? wrapped[methodName](_.identity)
|
|
||||||
: wrapped[methodName]();
|
|
||||||
|
|
||||||
ok(!(actual instanceof _));
|
ok(!(actual instanceof _));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -11187,7 +11190,8 @@
|
|||||||
_.each(funcs, function(methodName) {
|
_.each(funcs, function(methodName) {
|
||||||
test('`_(...).' + methodName + '` called without an `n` argument should return an unwrapped value', 1, function() {
|
test('`_(...).' + methodName + '` called without an `n` argument should return an unwrapped value', 1, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
strictEqual(typeof wrapped[methodName](), 'number');
|
var actual = wrapped[methodName]();
|
||||||
|
strictEqual(typeof actual, 'number');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest();
|
skipTest();
|
||||||
|
|||||||
Reference in New Issue
Block a user