-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.es6
77 lines (54 loc) · 1.57 KB
/
test.es6
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import test from 'prova';
import { stub } from 'sinon';
import { curry, curryN, curry1, curry2, curry3, curry4 } from './';
test('fj-curry#curry', (t) => {
t.plan(5);
let spy = stub().returns(true);
function func(a, b, c) {
return spy.apply(this, arguments);
}
t.equal(typeof curry, 'function');
t.equal(curry(func)(1, 2)(3, 4), true);
t.ok(spy.calledWith(1, 2, 3));
t.equal(curry(func)(1)(2, 3), true);
t.ok(spy.calledWith(1, 2, 3));
});
test('fj-curry#curryN', (t) => {
t.plan(7);
let spy = stub().returns(true);
t.equal(typeof curryN, 'function');
t.equal(curryN(1, spy)(1, 2), true);
t.ok(spy.calledWith(1));
t.equal(curryN(3, spy)(1, 2)(3, 4), true);
t.ok(spy.calledWith(1, 2, 3));
t.equal(curryN(3, spy)(1)(2, 3), true);
t.ok(spy.calledWith(1, 2, 3));
});
test('fj-curry#curry1', (t) => {
t.plan(3);
let spy = stub().returns(true);
t.equal(typeof curry1, 'function');
t.equal(curry1(spy)(1, 2), true);
t.ok(spy.calledWith(1));
});
test('fj-curry#curry2', (t) => {
t.plan(3);
let spy = stub().returns(true);
t.equal(typeof curry2, 'function');
t.equal(curry2(spy)(1)(2, 3), true);
t.ok(spy.calledWith(1, 2));
});
test('fj-curry#curry3', (t) => {
t.plan(3);
let spy = stub().returns(true);
t.equal(typeof curry3, 'function');
t.equal(curry3(spy)(1)(2)(3, 4), true);
t.ok(spy.calledWith(1, 2, 3));
});
test('fj-curry#curry4', (t) => {
t.plan(3);
let spy = stub().returns(true);
t.equal(typeof curry4, 'function');
t.equal(curry4(spy)(1)(2)(3)(4, 5), true);
t.ok(spy.calledWith(1, 2, 3, 4));
});