forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisNotEmpty.js
50 lines (39 loc) · 1.38 KB
/
isNotEmpty.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('isNotEmpty', function() {
it('returns true for null', function() {
eq(R.isNotEmpty(null), true);
});
it('returns true for undefined', function() {
eq(R.isNotEmpty(undefined), true);
});
it('returns false for empty string', function() {
eq(R.isNotEmpty(''), false);
eq(R.isNotEmpty(' '), true);
});
it('returns false for empty array', function() {
eq(R.isNotEmpty([]), false);
eq(R.isNotEmpty([[]]), true);
});
it('returns false for empty typed array', function() {
eq(R.isNotEmpty(Uint8Array.from('')), false);
eq(R.isNotEmpty(Float32Array.from('')), false);
eq(R.isNotEmpty(new Float32Array([])), false);
eq(R.isNotEmpty(Uint8Array.from('1')), true);
eq(R.isNotEmpty(Float32Array.from('1')), true);
eq(R.isNotEmpty(new Float32Array([1])), true);
});
it('returns false for empty object', function() {
eq(R.isNotEmpty({}), false);
eq(R.isNotEmpty({x: 0}), true);
});
it('returns false for empty arguments object', function() {
eq(R.isNotEmpty((function() { return arguments; })()), false);
eq(R.isNotEmpty((function() { return arguments; })(0)), true);
});
it('returns true for every other value', function() {
eq(R.isNotEmpty(0), true);
eq(R.isNotEmpty(NaN), true);
eq(R.isNotEmpty(['']), true);
});
});