mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Add lodash.prototype methods that return non-wrapped values.
Former-commit-id: b7ecb8c91ec9647827a80a297b966639c6580ef0
This commit is contained in:
@@ -697,8 +697,11 @@
|
||||
|
||||
object = lodash(1);
|
||||
equal(object.clone() instanceof lodash, false, '_(...) wrapped values are not chainable by default: ' + basename);
|
||||
equal(String(object) === '1', false, '_.prototype should not implement its own `toString` method: ' + basename);
|
||||
equal(Number(object) === 1 , false, '_.prototype should not implement its own `valueOf` method: ' + basename);
|
||||
equal(String(object) === '1', false, '_#toString should not be implemented: ' + basename);
|
||||
equal(Number(object) === 1 , false, '_#valueOf should not be implemented: ' + basename);
|
||||
|
||||
object.chain();
|
||||
equal(typeof object.has('x') == 'object', true, '_#has returns wrapped values when chaining: ' + basename);
|
||||
|
||||
start();
|
||||
});
|
||||
|
||||
50
test/test.js
50
test/test.js
@@ -1915,7 +1915,7 @@
|
||||
wrapped.shift();
|
||||
|
||||
deepEqual(wrapped.keys().value(), ['length']);
|
||||
equal(wrapped.first().value(), undefined);
|
||||
equal(wrapped.first(), undefined);
|
||||
});
|
||||
}());
|
||||
|
||||
@@ -1929,7 +1929,7 @@
|
||||
wrapped.splice(0, 1);
|
||||
|
||||
deepEqual(wrapped.keys().value(), ['length']);
|
||||
equal(wrapped.first().value(), undefined);
|
||||
equal(wrapped.first(), undefined);
|
||||
});
|
||||
}());
|
||||
|
||||
@@ -1957,6 +1957,52 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash(...) methods returning non-wrapped values');
|
||||
|
||||
(function() {
|
||||
var array = [1, 2, 3];
|
||||
|
||||
var funcs = [
|
||||
'contains',
|
||||
'every',
|
||||
'find',
|
||||
'first',
|
||||
'has',
|
||||
'isArguments',
|
||||
'isArray',
|
||||
'isBoolean',
|
||||
'isDate',
|
||||
'isElement',
|
||||
'isEmpty',
|
||||
'isEqual',
|
||||
'isFinite',
|
||||
'isFunction',
|
||||
'isNaN',
|
||||
'isNull',
|
||||
'isNumber',
|
||||
'isObject',
|
||||
'isPlainObject',
|
||||
'isRegExp',
|
||||
'isString',
|
||||
'isUndefined',
|
||||
'last',
|
||||
'reduce',
|
||||
'reduceRight',
|
||||
'some'
|
||||
];
|
||||
|
||||
_.each(funcs, function(methodName) {
|
||||
test('_.' + methodName + ' should return non-wrapped values', function() {
|
||||
var func = _[methodName],
|
||||
result = methodName == 'reduceRight' ? func(array, _.identity) : func;
|
||||
|
||||
notEqual(typeof result, 'object', '_.' + methodName + ' returns non-wrapped values');
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash methods');
|
||||
|
||||
(function() {
|
||||
|
||||
Reference in New Issue
Block a user