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

39
test/fromPairs.spec.js Normal file
View File

@@ -0,0 +1,39 @@
import lodashStable from 'lodash';
import { falsey, stubObject } from './utils';
import fromPairs from '../src/fromPairs';
import toPairs from '../src/toPairs';
describe('fromPairs', () => {
it('should accept a two dimensional array', () => {
const array = [
['a', 1],
['b', 2],
];
const object = { a: 1, b: 2 };
const actual = fromPairs(array);
expect(actual).toEqual(object);
});
it('should accept a falsey `array`', () => {
const expected = lodashStable.map(falsey, stubObject);
const actual = lodashStable.map(falsey, (array, index) => {
try {
return index ? fromPairs(array) : fromPairs();
} catch (e) {}
});
expect(actual).toEqual(expected);
});
it('should not support deep paths', () => {
const actual = fromPairs([['a.b', 1]]);
expect(actual).toEqual({ 'a.b': 1 });
});
it('should support consuming the return value of `_.toPairs`', () => {
const object = { 'a.b': 1 };
expect(fromPairs(toPairs(object))).toEqual(object);
});
});