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