UNPKG

bonsai-analyzer

Version:
24 lines (21 loc) 904 B
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _flatten = _interopRequireDefault(require("../flatten")); describe('flatten', () => { it('should take an array of arrays and return a single array', () => { const value = [[1], [2], [3]]; expect((0, _flatten.default)(value)).toEqual([1, 2, 3]); }); it('should take doubly-nested arrays and flatten one level deep', () => { const value = [[1], [2, [3], 4], [5]]; expect((0, _flatten.default)(value)).toEqual([1, 2, [3], 4, 5]); }); it('should flatten all types together', () => { const value = [[1], ['foo'], [null], [undefined], [{}]]; expect((0, _flatten.default)(value)).toEqual([1, 'foo', null, undefined, {}]); }); it('should skip empty inner arrays', () => { const value = [[], [], []]; expect((0, _flatten.default)(value)).toEqual([]); }); });