Home Reference Source Test Repository

buildDocs/flow.spec.js

import * as tslib_1 from "tslib";
import { expect } from 'chai';
import { Flow } from './flow';
describe('flow', () => {
    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([
            Flow('getName', (v) => v.toUpperCase())
        ], MyClass.prototype, "fn", null);
        const myClass = new MyClass();
        expect(myClass.fn()).to.equal('AVRY');
    });
    it('should compose and assign to the property', () => {
        class MyClass {
            constructor() {
                this.name = 'Avry';
            }
            getName() {
                expect(this, 'context').to.equal(myClass);
                return this.name;
            }
        }
        tslib_1.__decorate([
            Flow('getName', (v) => v.toUpperCase())
        ], MyClass.prototype, "fn", void 0);
        const myClass = new MyClass();
        expect(myClass.fn()).to.equal('AVRY');
    });
});