Home Reference Source Test Repository

buildDocs/curryRight.spec.js

import * as tslib_1 from "tslib";
import { expect } from 'chai';
import { CurryRight } from './curryRight';
describe('curryRight', () => {
    it('should curry the method with default arity', () => {
        class MyClass {
            add(a, b) {
                return [a, b];
            }
        }
        tslib_1.__decorate([
            CurryRight()
        ], MyClass.prototype, "add", null);
        const myClass = new MyClass();
        const set5 = myClass.add(5);
        expect(set5(10)).to.eql([10, 5]);
    });
    it('should retain the class context', () => {
        class MyClass {
            constructor() {
                this.value = 'blorg';
            }
            add(a, b) {
                return [a, b, this.value];
            }
        }
        tslib_1.__decorate([
            CurryRight()
        ], MyClass.prototype, "add", null);
        const myClass = new MyClass();
        const set5 = myClass.add(5);
        expect(set5(10)).to.eql([10, 5, 'blorg']);
    });
});