Loading files
import test from 'ava'
import { flatten } from './index.js'
test('array-utils: flatten() should flatten arrays into an array', (t) => {
let obs = flatten([1, 2, 3, 4])
let exp = [1, 2, 3, 4]
t.deepEqual(obs, exp)
obs = flatten([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
exp = [1, 2, 3, 4, 5, 6, 7, 8, 9]
t.deepEqual(obs, exp)
})
test('array-utils: flatten() should flatten arrays with arrays and values into an array', (t) => {
let obs = flatten([[1], 2, 3, [4]])
let exp = [1, 2, 3, 4]
t.deepEqual(obs, exp)
obs = flatten([1, [2, 3], 4])
exp = [1, 2, 3, 4]
t.deepEqual(obs, exp)
})
test('array-utils: flatten() should flatten heiarchy of arrays and values into an array', (t) => {
const obs = flatten([[1], [2, 3, [4, 5]], 6])
const exp = [1, 2, 3, 4, 5, 6]
t.deepEqual(obs, exp)
})
1c7200981This file is pinned to the selected release. Download the original to open it in your design tool.