Add _.drop, unit tests, and cleanup documentation for _.extend, _.defaults, and _.pick.

Former-commit-id: a45b0c45d52fdbe5f71984412d631f3dfe87965b
This commit is contained in:
John-David Dalton
2012-07-18 03:55:16 -04:00
parent a96d14566f
commit 9836b274b9
4 changed files with 92 additions and 18 deletions

View File

@@ -201,6 +201,34 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.drop');
(function() {
var object = { 'a': 1, 'b': 2, 'c': 3 },
actual = { 'b': 2 };
test('should accept individual property names', function() {
deepEqual(_.drop(object, 'a', 'c'), actual);
});
test('should accept an array of property names', function() {
deepEqual(_.drop(object, ['a', 'c']), actual);
});
test('should accept mixes of individual and arrays of property names', function() {
deepEqual(_.drop(object, ['a'], 'c'), actual);
});
test('should iterate over inherited properties', function() {
function Foo() {}
Foo.prototype = object;
deepEqual(_.drop(new Foo, 'a', 'c'), actual);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.escape');
(function() {
@@ -642,6 +670,19 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.pick');
(function() {
test('should iterate over inherited properties', function() {
function Foo() {}
Foo.prototype = { 'a': 1, 'b': 2, 'c': 3 };
deepEqual(_.pick(new Foo, 'b'), { 'b': 2 });
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.pluck');
(function() {