-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrying.test.js
More file actions
43 lines (36 loc) · 981 Bytes
/
currying.test.js
File metadata and controls
43 lines (36 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const curry = require('./currying');
function fn(arr)
{
return arr.reduce((pre,current) => pre+current, 0);
}
let curryC = curry(fn,3);
let curryB = curryC(6);
let curryA = curryB(3);
test('curry function with 3 arguments', function(){
expect(curryA(2)).toBe(11);
});
test('curry function with 3 arguments', function(){
expect(typeof(curryA(2))).toBe('number');
});
function fn2(arr)
{
return arr.map((current) => current.charAt(0));
}
let str=curry(fn2,2);
let str1 = str('margi');
test('curry function with 2 arguments', function(){
expect(str1('brahmbhatt')).toEqual(['m','b']);
});
let str2 = curry(fn2, 2);
let str3= str2('');
test('curry function with 2 arguments', function(){
expect(str3('brahmbhatt')).toEqual(['','b']);
});
str4 = curry(fn2, 1);
test('curry function with 1 argument', function(){
expect(str4('')).toEqual(['']);
});
// str5 = curry(fun2);
// test('curry function with 1 argument', function(){
// expect(str5()).toEqual([]);
// });