ts-prime
Version:
A utility library for JavaScript and Typescript.
29 lines (28 loc) • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var indexBy_1 = require("./indexBy");
var pipe_1 = require("./pipe");
var array = [
{ dir: 'left', code: 97 },
{ dir: 'right', code: 100 },
];
var expected = {
left: { dir: 'left', code: 97 },
right: { dir: 'right', code: 100 },
};
describe('data first', function () {
test('indexBy', function () {
expect(indexBy_1.indexBy(array, function (x) { return x.dir; })).toEqual(expected);
});
test('indexBy.indexed', function () {
expect(indexBy_1.indexBy.indexed(array, function (x) { return x.dir; })).toEqual(expected);
});
});
describe('data last', function () {
test('indexBy', function () {
expect(pipe_1.pipe(array, indexBy_1.indexBy(function (x) { return x.dir; }))).toEqual(expected);
});
test('indexBy.indexed', function () {
expect(pipe_1.pipe(array, indexBy_1.indexBy.indexed(function (x) { return x.dir; }))).toEqual(expected);
});
});