mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Add _.uniq test for arguments provided to iteratee.
This commit is contained in:
14
test/test.js
14
test/test.js
@@ -9052,7 +9052,7 @@
|
|||||||
strictEqual(func([curr, past]), isMax ? curr : past);
|
strictEqual(func([curr, past]), isMax ? curr : past);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should work with a `iteratee` argument', 1, function() {
|
test('`_.' + methodName + '` should work with an `iteratee` argument', 1, function() {
|
||||||
var actual = func(array, function(num) {
|
var actual = func(array, function(num) {
|
||||||
return -num;
|
return -num;
|
||||||
});
|
});
|
||||||
@@ -13578,7 +13578,7 @@
|
|||||||
deepEqual(_.uniq([1, 2, 3, 3, 3, 3, 3], true), expected);
|
deepEqual(_.uniq([1, 2, 3, 3, 3, 3, 3], true), expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work with `iteratee`', 2, function() {
|
test('should work with an `iteratee` argument', 2, function() {
|
||||||
_.each([objects, _.sortBy(objects, 'a')], function(array, index) {
|
_.each([objects, _.sortBy(objects, 'a')], function(array, index) {
|
||||||
var isSorted = !!index,
|
var isSorted = !!index,
|
||||||
expected = isSorted ? [objects[2], objects[0], objects[1]] : objects.slice(0, 3);
|
expected = isSorted ? [objects[2], objects[0], objects[1]] : objects.slice(0, 3);
|
||||||
@@ -13591,6 +13591,16 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should provide the correct `iteratee` arguments', 1, function() {
|
||||||
|
var args;
|
||||||
|
|
||||||
|
_.uniq(objects, function() {
|
||||||
|
args || (args = slice.call(arguments));
|
||||||
|
});
|
||||||
|
|
||||||
|
deepEqual(args, [objects[0], 0, objects]);
|
||||||
|
});
|
||||||
|
|
||||||
test('should work with `iteratee` without specifying `isSorted`', 1, function() {
|
test('should work with `iteratee` without specifying `isSorted`', 1, function() {
|
||||||
var actual = _.uniq(objects, function(object) {
|
var actual = _.uniq(objects, function(object) {
|
||||||
return object.a;
|
return object.a;
|
||||||
|
|||||||
Reference in New Issue
Block a user