From 419aa9dcbaa3f1da9e99575ab7ef539d6761a739 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 5 Aug 2013 22:11:38 -0700 Subject: [PATCH] Add find unit tests. Former-commit-id: 1dff5e55c73f91b4b877ee8e0cd4ad38655c49fb --- test/test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/test.js b/test/test.js index af997401c..83ac6b51d 100644 --- a/test/test.js +++ b/test/test.js @@ -957,11 +957,11 @@ _.forEach({ 'find': [objects[1], undefined, objects[2], objects[1]], - 'findLast': [objects[1], undefined, objects[2], objects[2]], + 'findLast': [objects[2], undefined, objects[2], objects[2]], 'findIndex': [1, -1, 2, 1], - 'findLastIndex': [1, -1, 2, 2], + 'findLastIndex': [2, -1, 2, 2], 'findKey': ['1', undefined, '2', '1'], - 'findLastKey': ['1', undefined, '2', '2'] + 'findLastKey': ['2', undefined, '2', '2'] }, function(expected, methodName) { QUnit.module('lodash.' + methodName); @@ -969,7 +969,11 @@ var func = _[methodName]; test('should return the correct value', function() { - strictEqual(func(objects, function(object) { return object.a == 1; }), expected[0]); + strictEqual(func(objects, function(object) { return object.a; }), expected[0]); + }); + + test('should work with a `thisArg`', function() { + strictEqual(func(objects, function(object, index) { return this[index].a; }, objects), expected[0]); }); test('should return `' + expected[1] + '` if value is not found', function() {