ts-prime
Version:
A utility library for JavaScript and Typescript.
26 lines (25 loc) • 1.02 kB
JavaScript
import { flatMap } from './flatMap';
import { pipe } from './pipe';
import { find } from './find';
import { createCounter } from './_counter';
describe('data_first', function () {
it('flatMap', function () {
var result = flatMap([1, 2], function (x) { return [x * 2, x * 3]; });
expect(result).toEqual([2, 3, 4, 6]);
});
});
describe('data_last', function () {
it('flatMap', function () {
var result = flatMap(function (x) { return [x * 2, x * 3]; })([1, 2]);
expect(result).toEqual([2, 3, 4, 6]);
});
describe('pipe', function () {
test('with find', function () {
var counter1 = createCounter();
var counter2 = createCounter();
var result = pipe([10, 20, 30, 40], counter1.fn(), flatMap(function (x) { return [x, x + 1, x + 2, x + 3]; }), counter2.fn(), find(function (x) { return x === 22; }));
expect(counter2.count).toHaveBeenCalledTimes(7);
expect(result).toEqual(22);
});
});
});