From 1090228628b00c3db87f57a0c1afab2134abf9d5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 13 Feb 2013 19:54:39 -0800 Subject: [PATCH] Add `_.groupBy` test for passing numbers for the `callback` argument. Former-commit-id: 6ce29f81f8688495a8a756e464b32e9e825c7857 --- test/test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test.js b/test/test.js index 8d562f7bd..9a8164deb 100644 --- a/test/test.js +++ b/test/test.js @@ -1014,6 +1014,17 @@ deepEqual(actual, { '4': [4.2], '6': [6.1, 6.4] }); }); + + test('should work with a number for `callback`', function() { + var array = [ + [1, 'a'], + [2, 'a'], + [2, 'b'] + ]; + + deepEqual(_.groupBy(array, 0), { '1': [[1 , 'a']], '2': [[2, 'a'], [2, 'b']] }); + deepEqual(_.groupBy(array, 1), { 'a': [[1 , 'a'], [2, 'a']], 'b': [[2, 'b']] }); + }); }()); /*--------------------------------------------------------------------------*/