mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
wip: migrate to bun
This commit is contained in:
30
test/shuffle.spec.ts
Normal file
30
test/shuffle.spec.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import assert from 'node:assert';
|
||||
import lodashStable from 'lodash';
|
||||
import shuffle from '../src/shuffle';
|
||||
|
||||
describe('shuffle', () => {
|
||||
const array = [1, 2, 3],
|
||||
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', () => {
|
||||
assert.deepStrictEqual(shuffle(array).sort(), array);
|
||||
assert.deepStrictEqual(shuffle(object).sort(), 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', () => {
|
||||
assert.deepStrictEqual(shuffle(1), []);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user