mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Use native Object.create when available, optimize the creation of lodash instances, and ensure methods like forEach return the existing wrapper object when chaining, instead of creating a new one.
Former-commit-id: fa9ec371ba23ce8c35c15a66dd9b1f09f183b3a9
This commit is contained in:
17
test/test.js
17
test/test.js
@@ -179,8 +179,8 @@
|
||||
ok(_() instanceof _);
|
||||
});
|
||||
|
||||
test('should return passed LoDash instances', function() {
|
||||
var wrapped = _([]);
|
||||
test('should return passed `lodash` instances', function() {
|
||||
var wrapped = _(false);
|
||||
equal(_(wrapped), wrapped);
|
||||
});
|
||||
}());
|
||||
@@ -810,11 +810,16 @@
|
||||
QUnit.module('lodash.forEach');
|
||||
|
||||
(function() {
|
||||
test('returns the collection', function() {
|
||||
test('should return the collection', function() {
|
||||
var collection = [1, 2, 3];
|
||||
equal(_.forEach(collection, Boolean), collection);
|
||||
});
|
||||
|
||||
test('should return the existing wrapper when chaining', function() {
|
||||
var wrapper = _([1, 2, 3]);
|
||||
equal(wrapper.forEach(Boolean), wrapper);
|
||||
});
|
||||
|
||||
_.each({
|
||||
'literal': 'abc',
|
||||
'object': Object('abc')
|
||||
@@ -901,6 +906,12 @@
|
||||
_.each(['assign', 'defaults', 'merge'], function(methodName) {
|
||||
var func = _[methodName];
|
||||
|
||||
test('should return the existing wrapper when chaining', function() {
|
||||
var wrapper = _({ 'a': 1 });
|
||||
equal(wrapper[methodName]({ 'b': 2 }), wrapper);
|
||||
});
|
||||
|
||||
|
||||
test('lodash.' + methodName + ' should assign problem JScript properties (test in IE < 9)', function() {
|
||||
var object = {
|
||||
'constructor': '0',
|
||||
|
||||
Reference in New Issue
Block a user