Add object iteration unit tests for _.max, _.min, _.shuffle.

Former-commit-id: 45129100fbbfa14610cacb055c1fa393ae6ce153
This commit is contained in:
John-David Dalton
2012-10-09 00:59:55 -07:00
parent 1708663b32
commit d174b13111

View File

@@ -947,6 +947,19 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.max and lodash.min object iteration');
_.each(['max', 'min'], function(methodName) {
var func = _[methodName];
test('lodash.' + methodName + ' should iterate an object', function() {
var actual = func({ 'a': 1, 'b': 2, 'c': 3 });
equal(actual, methodName == 'max' ? 3 : 1);
});
});
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.merge');
(function() {
@@ -991,7 +1004,6 @@
source.bar.b = source.foo.b;
var actual = _.merge(object, source);
ok(actual.bar.b === actual.foo.b && actual.foo.b.foo.c === actual.foo.b.foo.c.foo.b.foo.c);
});
@@ -1315,6 +1327,17 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.shuffle');
(function() {
test('should shuffle an object', function() {
var actual = _.shuffle({ 'a': 1, 'b': 2, 'c': 3 });
deepEqual(actual.sort(), [1, 2, 3]);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.size');
(function() {