mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Add object iteration unit tests for _.max, _.min, _.shuffle.
Former-commit-id: 45129100fbbfa14610cacb055c1fa393ae6ce153
This commit is contained in:
25
test/test.js
25
test/test.js
@@ -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');
|
QUnit.module('lodash.merge');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
@@ -991,7 +1004,6 @@
|
|||||||
source.bar.b = source.foo.b;
|
source.bar.b = source.foo.b;
|
||||||
|
|
||||||
var actual = _.merge(object, source);
|
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);
|
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');
|
QUnit.module('lodash.size');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user