forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjuxt.js
50 lines (37 loc) · 1.26 KB
/
juxt.js
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
44
45
46
47
48
49
50
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('juxt', function() {
function hello() { return 'hello'; }
function bye() { return 'bye'; }
it('works with no functions and no values', function() {
eq(R.juxt([])(), []);
});
it('works with no functions and some values', function() {
eq(R.juxt([])(2, 3), []);
});
it('works with 1 function and no values', function() {
eq(R.juxt([hello])(), ['hello']);
});
it('works with 1 function and 1 value', function() {
eq(R.juxt([R.add(3)])(2), [5]);
});
it('works with 1 function and some values', function() {
eq(R.juxt([R.multiply])(2, 3), [6]);
});
it('works with some functions and no values', function() {
eq(R.juxt([hello, bye])(), ['hello', 'bye']);
});
it('works with some functions and 1 value', function() {
eq(R.juxt([R.multiply(2), R.add(3)])(2), [4, 5]);
});
it('works with some functions and some values', function() {
eq(R.juxt([R.add, R.multiply])(2, 3), [5, 6]);
});
it('retains the highest arity', function() {
var f = R.juxt([R.nAry(1, R.T), R.nAry(3, R.T), R.nAry(2, R.T)]);
eq(f.length, 3);
});
it('returns a curried function', function() {
eq(R.juxt([R.multiply, R.add])(2)(3), [6, 5]);
});
});