-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.es6
51 lines (41 loc) · 1.07 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
import assert from 'assert';
import always from 'fj-always';
import cond from './';
function isOk(y, done) {
return (x) => {
assert.equal(y, x);
done();
};
}
describe('fj-cond', () => {
let T = always(true);
let isT = (x) => x === true;
let eq = (x) => (y) => x === y;
it('should call the first function whichs predicate is true', (done) => {
assert.equal(cond([
[isT, isOk(true, done)],
[T, assert.fail]
])(true));
});
it('should call the first function whichs predicate is true', (done) => {
assert.equal(cond([
[eq(1), assert.fail],
[eq(2), isOk(2, done)],
[T, assert.fail]
])(2));
});
it('should call the first function whichs predicate is true', (done) => {
assert.equal(cond([
[eq(1), assert.fail],
[eq(2), assert.fail],
[eq(3), isOk(3, done)],
[T, assert.fail]
])(3));
});
it('should call the first function whichs predicate is true', (done) => {
assert.equal(cond([
[eq(1), assert.fail],
[T, isOk(2, done)]
])(2));
});
});