UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

24 lines (23 loc) 838 B
import { flattenDeep } from './flattenDeep'; import { pipe } from './pipe'; import { find } from './find'; import { createCounter } from './_counter'; test('flatten', function () { expect(flattenDeep([[1, 2], 3, [4, 5]])).toEqual([1, 2, 3, 4, 5]); }); test('nested', function () { expect(flattenDeep([ [1, 2], [[3], [4, 5]], ])).toEqual([1, 2, 3, 4, 5]); }); describe('pipe', function () { test('with find', function () { var counter1 = createCounter(); var counter2 = createCounter(); var result = pipe([[1, 2], [[3]], [[4, 5]]], counter1.fn(), flattenDeep(), counter2.fn(), find(function (x) { return x - 1 === 2; })); expect(counter1.count).toHaveBeenCalledTimes(2); expect(counter2.count).toHaveBeenCalledTimes(3); expect(result).toEqual(3); }); });