build: cleanup eslint configuration
[e-mobility-charging-stations-simulator.git] / tests / utils / Utils.test.ts
index 5592e68f3800d40ea888af761b5a4d1e98fb48d8..615f76fa01f057c9bad1a1b60a7a0d16b4df54d4 100644 (file)
@@ -58,13 +58,15 @@ await describe('Utils test suite', async () => {
   });
 
   await it('Verify formatDurationMilliSeconds()', () => {
-    expect(formatDurationMilliSeconds(0)).toBe('');
+    expect(formatDurationMilliSeconds(0)).toBe('0 seconds');
+    expect(formatDurationMilliSeconds(900)).toBe('0 seconds');
     expect(formatDurationMilliSeconds(1000)).toBe('1 second');
     expect(formatDurationMilliSeconds(hoursToMilliseconds(4380))).toBe('182 days 12 hours');
   });
 
   await it('Verify formatDurationSeconds()', () => {
-    expect(formatDurationSeconds(0)).toBe('');
+    expect(formatDurationSeconds(0)).toBe('0 seconds');
+    expect(formatDurationSeconds(0.9)).toBe('0 seconds');
     expect(formatDurationSeconds(1)).toBe('1 second');
     expect(formatDurationSeconds(hoursToSeconds(4380))).toBe('182 days 12 hours');
   });
@@ -89,8 +91,9 @@ await describe('Utils test suite', async () => {
 
   await it('Verify convertToDate()', () => {
     expect(convertToDate(undefined)).toBe(undefined);
-    expect(() => convertToDate('')).toThrowError(new Error("Cannot convert to date: ''"));
-    expect(() => convertToDate('00:70:61')).toThrowError(
+    expect(convertToDate(null)).toBe(null);
+    expect(() => convertToDate('')).toThrow(new Error("Cannot convert to date: ''"));
+    expect(() => convertToDate('00:70:61')).toThrow(
       new Error("Cannot convert to date: '00:70:61'"),
     );
     expect(convertToDate(0)).toStrictEqual(new Date('1970-01-01T00:00:00.000Z'));
@@ -179,13 +182,13 @@ await describe('Utils test suite', async () => {
     randomInteger = getRandomInteger(0, -Constants.MAX_RANDOM_INTEGER);
     expect(randomInteger).toBeGreaterThanOrEqual(-Constants.MAX_RANDOM_INTEGER);
     expect(randomInteger).toBeLessThanOrEqual(0);
-    expect(() => getRandomInteger(0, 1)).toThrowError(
+    expect(() => getRandomInteger(0, 1)).toThrow(
       'The value of "max" is out of range. It must be greater than the value of "min" (1). Received 1',
     );
-    expect(() => getRandomInteger(-1)).toThrowError(
+    expect(() => getRandomInteger(-1)).toThrow(
       'The value of "max" is out of range. It must be greater than the value of "min" (0). Received 0',
     );
-    expect(() => getRandomInteger(Constants.MAX_RANDOM_INTEGER + 1)).toThrowError(
+    expect(() => getRandomInteger(Constants.MAX_RANDOM_INTEGER + 1)).toThrow(
       `The value of "max" is out of range. It must be <= ${
         Constants.MAX_RANDOM_INTEGER + 1
       }. Received 281_474_976_710_656`,
@@ -221,8 +224,8 @@ await describe('Utils test suite', async () => {
     expect(randomFloat).toBeGreaterThanOrEqual(0);
     expect(randomFloat).toBeLessThanOrEqual(Number.MAX_VALUE);
     expect(randomFloat).not.toEqual(getRandomFloat());
-    expect(() => getRandomFloat(0, 1)).toThrowError(new RangeError('Invalid interval'));
-    expect(() => getRandomFloat(Number.MAX_VALUE, -Number.MAX_VALUE)).toThrowError(
+    expect(() => getRandomFloat(0, 1)).toThrow(new RangeError('Invalid interval'));
+    expect(() => getRandomFloat(Number.MAX_VALUE, -Number.MAX_VALUE)).toThrow(
       new RangeError('Invalid interval'),
     );
     randomFloat = getRandomFloat(0, -Number.MAX_VALUE);