Home Reference Source Test Repository

buildDocs/flowRight.spec.js

import * as tslib_1 from "tslib";
import { expect } from 'chai';
import { FlowRight } from './flowRight';
describe('flowRight', () => {
    it('should compose the functions', () => {
        class MyClass {
            constructor() {
                this.name = 'Avry';
            }
            fn(...args) {
                return args[0];
            }
            getName() {
                expect(this, 'context').to.equal(myClass);
                return this.name;
            }
        }
        tslib_1.__decorate([
            FlowRight((v) => v.toUpperCase(), 'getName')
        ], MyClass.prototype, "fn", null);
        const myClass = new MyClass();
        expect(myClass.fn()).to.equal('AVRY');
    });
    it('should compose the property', () => {
        class MyClass {
            constructor() {
                this.name = 'Avry';
            }
            getName() {
                expect(this, 'context').to.equal(myClass);
                return this.name;
            }
        }
        tslib_1.__decorate([
            FlowRight((v) => v.toUpperCase(), 'getName')
        ], MyClass.prototype, "fn", void 0);
        const myClass = new MyClass();
        expect(myClass.fn()).to.equal('AVRY');
    });
});