import { liftChildren } from './arrays'; describe('array utils', function () { describe('liftChildren(): ', function () { it('should do nothing if no children of specified propName', function () { const items = [{ foo: 'bar' }, { foo: 'fizz' }]; const result = liftChildren('bar', items); expect(result).toEqual(items); }); it('should do nothing with non-object arrays', function () { const items = ['fizz', 'bar']; const result = liftChildren('foo', items); expect(result).toEqual(items); }); it('should move children items to the top level array', function () { const items = [{ foo: [{ fizz: 'buzz' }] }, { bar: 'foo' }]; const result = liftChildren('foo', items); const expected = [{ foo: [{ fizz: 'buzz' }] }, { fizz: 'buzz' }, { bar: 'foo' }]; expect(result).toEqual(expected); }); }); });