UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

28 lines (27 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var reduce_1 = require("./reduce"); var pipe_1 = require("./pipe"); var array = [1, 2, 3, 4, 5]; describe('data first', function () { test('reduce', function () { expect(reduce_1.reduce(array, function (acc, x) { return acc + x; }, 100)).toEqual(115); }); test('reduce.indexed', function () { var i = 0; expect(reduce_1.reduce.indexed(array, function (acc, x, index, items) { expect(index).toBe(i); expect(items).toBe(array); i++; return acc + x; }, 100)).toEqual(115); }); }); describe('data last', function () { test('reduce', function () { expect(pipe_1.pipe(array, reduce_1.reduce(function (acc, x) { return acc + x; }, 100))).toEqual(115); }); test('reduce.indexed', function () { expect(pipe_1.pipe(array, reduce_1.reduce.indexed(function (acc, x) { return acc + x; }, 100))).toEqual(115); }); });