Add string test for _.sample.

Former-commit-id: 81836be99bc0439d24eb5e6b73a7e6c2803c9516
This commit is contained in:
John-David Dalton
2013-08-16 23:33:13 -07:00
parent 82c17dbde2
commit 2abae2f21a

View File

@@ -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]));
});
});
}());
/*--------------------------------------------------------------------------*/