mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
wip: code formatting nits continued
This commit is contained in:
29
test/shuffle.spec.js
Normal file
29
test/shuffle.spec.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import lodashStable from 'lodash';
|
||||
import shuffle from '../src/shuffle';
|
||||
|
||||
describe('shuffle', () => {
|
||||
const array = [1, 2, 3];
|
||||
const object = { a: 1, b: 2, c: 3 };
|
||||
|
||||
it('should return a new array', () => {
|
||||
assert.notStrictEqual(shuffle(array), array);
|
||||
});
|
||||
|
||||
it('should contain the same elements after a collection is shuffled', () => {
|
||||
expect(shuffle(array).sort()).toEqual(array);
|
||||
expect(shuffle(object).sort()).toEqual(array);
|
||||
});
|
||||
|
||||
it('should shuffle small collections', () => {
|
||||
const actual = lodashStable.times(1000, () => shuffle([1, 2]));
|
||||
|
||||
assert.deepStrictEqual(lodashStable.sortBy(lodashStable.uniqBy(actual, String), '0'), [
|
||||
[1, 2],
|
||||
[2, 1],
|
||||
]);
|
||||
});
|
||||
|
||||
it('should treat number values for `collection` as empty', () => {
|
||||
expect(shuffle(1)).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user