tsoid
Version:
Typed functional library to deal with async operations.
25 lines (24 loc) • 956 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const compose_1 = require("../compose");
describe('compose', () => {
const double = (x) => x * 2;
const triple = (x) => x * 3;
const isEven = (x) => x % 2 === 0;
it('Composing three functions should return the right value', () => {
const fn = compose_1.default(isEven, double, triple);
expect(fn(3)).toBe(true);
});
it('Composing two functon should return the right value', () => {
const fn = compose_1.default(isEven, triple);
expect(fn(3)).toBe(false);
});
it('Should print right composition', () => {
const fn1 = (arg) => `fn1(${arg})`;
const fn2 = (arg) => `fn2(${arg})`;
const fn3 = (arg) => `fn3(${arg})`;
const fn4 = (arg) => `fn4(${arg})`;
const composed = compose_1.default(fn1, fn2, fn3, fn4);
expect(composed(1)).toBe('fn1(fn2(fn3(fn4(1))))');
});
});