-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
90 lines (62 loc) · 1.82 KB
/
test.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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
"use strict";
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var test = _interopRequire(require("prova"));
var stub = require("sinon").stub;
var _ = require("./");
var curry = _.curry;
var curryN = _.curryN;
var curry1 = _.curry1;
var curry2 = _.curry2;
var curry3 = _.curry3;
var curry4 = _.curry4;
test("fj-curry#curry", function (t) {
t.plan(5);
var 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", function (t) {
t.plan(7);
var 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", function (t) {
t.plan(3);
var 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", function (t) {
t.plan(3);
var 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", function (t) {
t.plan(3);
var 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", function (t) {
t.plan(3);
var 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));
});