mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Add chaining tests.
This commit is contained in:
65
test/test.js
65
test/test.js
@@ -1051,6 +1051,16 @@
|
||||
strictEqual(func(Object(string)), expected);
|
||||
strictEqual(func({ 'toString': _.constant(string) }), expected);
|
||||
});
|
||||
|
||||
test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() {
|
||||
if (!isNpm) {
|
||||
var actual = _('hello world')[methodName]();
|
||||
strictEqual(actual, expected);
|
||||
}
|
||||
else {
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -1081,6 +1091,16 @@
|
||||
strictEqual(_.capitalize('Fred'), 'Fred');
|
||||
strictEqual(_.capitalize(' fred'), ' fred');
|
||||
});
|
||||
|
||||
test('should return an unwrapped value when chaining', 1, function() {
|
||||
if (!isNpm) {
|
||||
var actual = _('fred').capitalize();
|
||||
strictEqual(actual, 'Fred');
|
||||
}
|
||||
else {
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -1312,7 +1332,7 @@
|
||||
});
|
||||
|
||||
test('`_.' + methodName + '` should handle cloning if `callback` returns `undefined`', 1, function() {
|
||||
var actual = func({ 'a': { 'b': 'c' } }, function() {});
|
||||
var actual = func({ 'a': { 'b': 'c' } }, _.noop);
|
||||
deepEqual(actual, { 'a': { 'b': 'c' } });
|
||||
});
|
||||
|
||||
@@ -1346,6 +1366,19 @@
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
|
||||
test('`_.' + methodName + '` should return a unwrapped value when chaining', 2, function() {
|
||||
if (!isNpm) {
|
||||
var object = objects['an object'],
|
||||
actual = _(object)[methodName]();
|
||||
|
||||
deepEqual(actual, object);
|
||||
notStrictEqual(actual, object);
|
||||
}
|
||||
else {
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
});
|
||||
}(1, 2, 3));
|
||||
|
||||
@@ -1358,6 +1391,16 @@
|
||||
var array = ['0', '1', '2'];
|
||||
deepEqual(_.compact(falsey.concat(array)), array);
|
||||
});
|
||||
|
||||
test('should return a wrapped value when chaining', 1, function() {
|
||||
if (!isNpm) {
|
||||
var actual = _(falsey).compact();
|
||||
ok(actual instanceof _);
|
||||
}
|
||||
else {
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -1386,6 +1429,16 @@
|
||||
test('should return a new function', 1, function() {
|
||||
notStrictEqual(_.compose(_.noop), _.noop);
|
||||
});
|
||||
|
||||
test('should return a wrapped value when chaining', 1, function() {
|
||||
if (!isNpm) {
|
||||
var actual = _(_.noop).compose();
|
||||
ok(actual instanceof _);
|
||||
}
|
||||
else {
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -1423,6 +1476,16 @@
|
||||
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should return a wrapped value when chaining', 1, function() {
|
||||
if (!isNpm) {
|
||||
var actual = _(true).constant();
|
||||
ok(actual instanceof _);
|
||||
}
|
||||
else {
|
||||
skipTest();
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user