buildDocs/curry.spec.js
import * as tslib_1 from "tslib";
import { expect } from 'chai';
import { Curry } from './curry';
describe('curry', () => {
it('should curry the method with default arity', () => {
class MyClass {
add(a, b) {
return a + b;
}
}
tslib_1.__decorate([
Curry()
], MyClass.prototype, "add", null);
const myClass = new MyClass();
const add5 = myClass.add(5);
expect(add5).to.be.an.instanceOf(Function);
expect(add5(10)).to.equal(15);
});
it('should curry the method with fixed arity', () => {
class MyClass {
add(a, b, c) {
return a + b * c;
}
}
tslib_1.__decorate([
Curry(2)
], MyClass.prototype, "add", null);
const myClass = new MyClass();
const add5 = myClass.add(5);
expect(add5).to.be.an.instanceOf(Function);
expect(add5(10, 2)).to.equal(25);
});
it('should retain the class context', () => {
class MyClass {
constructor() {
this.value = 10;
}
add(a, b) {
return (a + b) * this.value;
}
}
tslib_1.__decorate([
Curry()
], MyClass.prototype, "add", null);
const myClass = new MyClass();
const add5 = myClass.add(5);
expect(add5(2)).to.equal(70);
});
});