@@ -40,6 +40,49 @@ describe("Utils", function () {
40
40
assert . isTrue ( utils . isUndefined ( arr ) ) ;
41
41
} ) ;
42
42
43
+ describe ( "isEmpty" , function ( ) {
44
+ it ( "should return true for null values" , function ( ) {
45
+ assert . isTrue ( utils . isEmpty ( null ) ) ;
46
+ } ) ;
47
+
48
+ it ( "should return true for undefined values" , function ( ) {
49
+ assert . isTrue ( utils . isEmpty ( undefined ) ) ;
50
+ } ) ;
51
+
52
+ it ( "should return true for NaN values" , function ( ) {
53
+ assert . isTrue ( utils . isEmpty ( NaN ) ) ;
54
+ } ) ;
55
+
56
+ it ( "should return false for strings (including empty strings)" , function ( ) {
57
+ assert . isFalse ( utils . isEmpty ( "" ) ) ;
58
+ assert . isFalse ( utils . isEmpty ( " " ) ) ;
59
+ assert . isFalse ( utils . isEmpty ( "hello" ) ) ;
60
+ } ) ;
61
+
62
+ it ( "should return false for numbers (except NaN)" , function ( ) {
63
+ assert . isFalse ( utils . isEmpty ( 0 ) ) ;
64
+ assert . isFalse ( utils . isEmpty ( - 1 ) ) ;
65
+ assert . isFalse ( utils . isEmpty ( 42.5 ) ) ;
66
+ } ) ;
67
+
68
+ it ( "should return false for BigInt values" , function ( ) {
69
+ assert . isFalse ( utils . isEmpty ( BigInt ( 9007199254740991 ) ) ) ;
70
+ assert . isFalse ( utils . isEmpty ( BigInt ( 0 ) ) ) ;
71
+ } ) ;
72
+
73
+ it ( "should return false for objects and arrays" , function ( ) {
74
+ assert . isFalse ( utils . isEmpty ( { } ) ) ;
75
+ assert . isFalse ( utils . isEmpty ( [ ] ) ) ;
76
+ assert . isFalse ( utils . isEmpty ( { key : "value" } ) ) ;
77
+ assert . isFalse ( utils . isEmpty ( [ 1 , 2 , 3 ] ) ) ;
78
+ } ) ;
79
+
80
+ it ( "should return false for boolean values" , function ( ) {
81
+ assert . isFalse ( utils . isEmpty ( true ) ) ;
82
+ assert . isFalse ( utils . isEmpty ( false ) ) ;
83
+ } ) ;
84
+ } ) ;
85
+
43
86
it ( "Checks if value is a valid Date object" , function ( ) {
44
87
let date1 = new Date ( ) ;
45
88
let date2 = "2021-01-01 00:00:00" ;
0 commit comments