wip: code formatting nits continued

This commit is contained in:
jdalton
2023-09-16 22:59:56 -07:00
parent 0b28b7f7b6
commit b5c59317ea
421 changed files with 7354 additions and 9005 deletions

31
test/sample.spec.js Normal file
View File

@@ -0,0 +1,31 @@
import lodashStable from 'lodash';
import { empties, noop } from './utils';
import sample from '../src/sample';
describe('sample', () => {
const array = [1, 2, 3];
it('should return a random element', () => {
const actual = sample(array);
expect(lodashStable.includes(array, actual));
});
it('should return `undefined` when sampling empty collections', () => {
const expected = lodashStable.map(empties, noop);
const actual = lodashStable.transform(empties, (result, value) => {
try {
result.push(sample(value));
} catch (e) {}
});
expect(actual).toEqual(expected);
});
it('should sample an object', () => {
const object = { a: 1, b: 2, c: 3 };
const actual = sample(object);
expect(lodashStable.includes(array, actual));
});
});