* chore: make aware eslint that we use jest By setting up the jest environment, we no longer need to declare the 'test' global in the configuration. * chore: don't need to import expect, it's a jest environment global * chore: don't need to import expect when creating undefined test
24 lines
601 B
JavaScript
24 lines
601 B
JavaScript
const {uncurry} = require('./_30s.js');
|
|
|
|
test('uncurry is a Function', () => {
|
|
expect(uncurry).toBeInstanceOf(Function);
|
|
});
|
|
const add = x => y => z => x + y + z;
|
|
const add1 = uncurry(add);
|
|
const add2 = uncurry(add, 2);
|
|
const add3 = uncurry(add, 3);
|
|
test('Works without a provided value for n', () => {
|
|
expect(add1(1)(2)(3)).toBe(6);
|
|
});
|
|
test('Works with n = 2', () => {
|
|
expect(add2(1, 2)(3)).toBe(6);
|
|
});
|
|
test('Works with n = 3', () => {
|
|
expect(add3(1, 2, 3)).toBe(6);
|
|
});
|
|
test('Throws RangeError if arguments are too few', () => {
|
|
expect(() => {
|
|
add2(2);
|
|
}).toThrow(RangeError);
|
|
});
|