From 2abae2f21a0970a18cd61c4e9ac29bca335018ee Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 16 Aug 2013 23:33:13 -0700 Subject: [PATCH] Add string test for `_.sample`. Former-commit-id: 81836be99bc0439d24eb5e6b73a7e6c2803c9516 --- test/test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test.js b/test/test.js index f8a29a5f1..4711200eb 100644 --- a/test/test.js +++ b/test/test.js @@ -3298,6 +3298,20 @@ var actual = _(array).sample(); ok(_.contains(array, actual)); }); + + _.forEach({ + 'literal': 'abc', + 'object': Object('abc') + }, + function(collection, key) { + test('should work with a string ' + key + ' for `collection`', function() { + var actual = _.sample(collection); + ok(_.contains(collection, actual)); + + actual = _.sample(collection, 2); + ok(actual[0] !== actual[1] && _.contains(collection, actual[0]) && _.contains(collection, actual[1])); + }); + }); }()); /*--------------------------------------------------------------------------*/