mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Add string test for _.sample.
Former-commit-id: 81836be99bc0439d24eb5e6b73a7e6c2803c9516
This commit is contained in:
14
test/test.js
14
test/test.js
@@ -3298,6 +3298,20 @@
|
|||||||
var actual = _(array).sample();
|
var actual = _(array).sample();
|
||||||
ok(_.contains(array, actual));
|
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]));
|
||||||
|
});
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user