fix(simulator): detect string emptyness properly
[e-mobility-charging-stations-simulator.git] / test / utils / UtilsTest.ts
index 21d5d1376a7bbd3ccd0daf8390ac36f5897a2c4c..9d694308fdda835948be94afc7c7c8e98656ec13 100644 (file)
@@ -149,9 +149,15 @@ describe('Utils test suite', () => {
     expect(Utils.isIterable('')).toBe(true);
     expect(Utils.isIterable(' ')).toBe(true);
     expect(Utils.isIterable('test')).toBe(true);
-    expect(Utils.isIterable(null)).toBe(false);
     expect(Utils.isIterable(undefined)).toBe(false);
-    expect(Utils.isIterable([])).toBe(true);
+    expect(Utils.isIterable(null)).toBe(false);
+    expect(Utils.isIterable(0)).toBe(false);
+    expect(Utils.isIterable([0, 1])).toBe(true);
+    expect(Utils.isIterable({ 1: 1 })).toBe(false);
+    expect(Utils.isIterable(new Map())).toBe(true);
+    expect(Utils.isIterable(new Set())).toBe(true);
+    expect(Utils.isIterable(new WeakMap())).toBe(false);
+    expect(Utils.isIterable(new WeakSet())).toBe(false);
   });
 
   it('Verify isEmptyString()', () => {
@@ -161,8 +167,8 @@ describe('Utils test suite', () => {
     expect(Utils.isEmptyString('test')).toBe(false);
     expect(Utils.isEmptyString(' test')).toBe(false);
     expect(Utils.isEmptyString('test ')).toBe(false);
-    expect(Utils.isEmptyString(null)).toBe(false);
-    expect(Utils.isEmptyString(undefined)).toBe(false);
+    expect(Utils.isEmptyString(undefined)).toBe(true);
+    expect(Utils.isEmptyString(null)).toBe(true);
     expect(Utils.isEmptyString(0)).toBe(false);
     expect(Utils.isEmptyString({})).toBe(false);
     expect(Utils.isEmptyString([])).toBe(false);
@@ -172,6 +178,24 @@ describe('Utils test suite', () => {
     expect(Utils.isEmptyString(new WeakSet())).toBe(false);
   });
 
+  it('Verify isNotEmptyString()', () => {
+    expect(Utils.isNotEmptyString('')).toBe(false);
+    expect(Utils.isNotEmptyString(' ')).toBe(false);
+    expect(Utils.isNotEmptyString('     ')).toBe(false);
+    expect(Utils.isNotEmptyString('test')).toBe(true);
+    expect(Utils.isNotEmptyString(' test')).toBe(true);
+    expect(Utils.isNotEmptyString('test ')).toBe(true);
+    expect(Utils.isNotEmptyString(undefined)).toBe(false);
+    expect(Utils.isNotEmptyString(null)).toBe(false);
+    expect(Utils.isNotEmptyString(0)).toBe(false);
+    expect(Utils.isNotEmptyString({})).toBe(false);
+    expect(Utils.isNotEmptyString([])).toBe(false);
+    expect(Utils.isNotEmptyString(new Map())).toBe(false);
+    expect(Utils.isNotEmptyString(new Set())).toBe(false);
+    expect(Utils.isNotEmptyString(new WeakMap())).toBe(false);
+    expect(Utils.isNotEmptyString(new WeakSet())).toBe(false);
+  });
+
   it('Verify isUndefined()', () => {
     expect(Utils.isUndefined(undefined)).toBe(true);
     expect(Utils.isUndefined(null)).toBe(false);
@@ -186,8 +210,8 @@ describe('Utils test suite', () => {
   });
 
   it('Verify isNullOrUndefined()', () => {
-    expect(Utils.isNullOrUndefined(null)).toBe(true);
     expect(Utils.isNullOrUndefined(undefined)).toBe(true);
+    expect(Utils.isNullOrUndefined(null)).toBe(true);
     expect(Utils.isNullOrUndefined('')).toBe(false);
     expect(Utils.isNullOrUndefined(0)).toBe(false);
     expect(Utils.isNullOrUndefined({})).toBe(false);
@@ -201,8 +225,8 @@ describe('Utils test suite', () => {
   it('Verify isEmptyArray()', () => {
     expect(Utils.isEmptyArray([])).toBe(true);
     expect(Utils.isEmptyArray([1, 2])).toBe(false);
-    expect(Utils.isEmptyArray(null)).toBe(true);
     expect(Utils.isEmptyArray(undefined)).toBe(true);
+    expect(Utils.isEmptyArray(null)).toBe(true);
     expect(Utils.isEmptyArray('')).toBe(true);
     expect(Utils.isEmptyArray('test')).toBe(true);
     expect(Utils.isEmptyArray(0)).toBe(true);
@@ -216,8 +240,8 @@ describe('Utils test suite', () => {
   it('Verify isEmptyObject()', () => {
     expect(Utils.isEmptyObject({})).toBe(true);
     expect(Utils.isEmptyObject({ 1: 1, 2: 2 })).toBe(false);
-    expect(Utils.isEmptyObject(null)).toBe(false);
     expect(Utils.isEmptyObject(undefined)).toBe(false);
+    expect(Utils.isEmptyObject(null)).toBe(false);
     expect(Utils.isEmptyObject(new Map())).toBe(false);
     expect(Utils.isEmptyObject(new Set())).toBe(false);
     expect(Utils.isEmptyObject(new WeakMap())).toBe(false);