forked from angus-c/just
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (30 loc) · 807 Bytes
/
Copy pathindex.js
File metadata and controls
34 lines (30 loc) · 807 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
var test = require('../util/test')(__filename);
var flip = require('../../packages/function-flip');
test('flips the first two args', function(t) {
t.plan(1);
var flippedArray = flip(Array);
t.same(flippedArray(0, 1), [1, 0]);
t.end();
});
test('includes the rest of the args in original order', function(t) {
t.plan(1);
var flippedArray = flip(Array);
t.same(flippedArray(2, 3, 5, 8, 13), [3, 2, 5, 8, 13]);
t.end();
});
test('does nothing with zero arity functions', function(t) {
t.plan(1);
function fn() {
return 21;
}
t.equal(21, flip(fn)(34));
t.end();
});
test('still flips the first two args of a variadic function', function(t) {
t.plan(1);
function pair() {
return [].slice.call(arguments, 0, 2);
}
t.same([55, 89], flip(pair)(89, 55));
t.end();
});