-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathis_empty.js
More file actions
46 lines (39 loc) · 1.28 KB
/
is_empty.js
File metadata and controls
46 lines (39 loc) · 1.28 KB
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
import { PRINTABLE_ASCII } from '../const';
import v from '../voca';
describe('isEmpty', function() {
it('should return true for an empty string', function() {
expect(v.isEmpty('')).toBe(true);
});
it('should return true for an undefined', function() {
expect(v.isEmpty(undefined)).toBe(true);
expect(v.isEmpty()).toBe(true);
});
it('should return true for a null', function() {
expect(v.isEmpty(null)).toBe(true);
});
it('should return false for a non empty string', function() {
expect(v.isEmpty('Hello World!')).toBe(false);
expect(v.isEmpty('a')).toBe(false);
expect(v.isEmpty(' ')).toBe(false);
expect(v.isEmpty(PRINTABLE_ASCII)).toBe(false);
});
it('should return false for a non empty string representation of an object', function() {
expect(v.isEmpty(['Hello world'])).toBe(false);
expect(
v.isEmpty({
toString: function() {
return ' ';
},
})
).toBe(false);
});
it('should return false for a boolean', function() {
expect(v.isEmpty(true)).toBe(false);
expect(v.isEmpty(false)).toBe(false);
});
it('should return false for a number', function() {
expect(v.isEmpty(0)).toBe(false);
expect(v.isEmpty(100)).toBe(false);
expect(v.isEmpty(-1.5)).toBe(false);
});
});