refactor: improve time handling code
[e-mobility-charging-stations-simulator.git] / test / utils / Utils.test.ts
index 5b9f81515c9686bcbea50afe1b781b3d6c108036..2b6df881b921f3533b285c8f1c3df7a8f6dd1431 100644 (file)
@@ -1,3 +1,4 @@
+import { hoursToMilliseconds } from 'date-fns';
 import { expect } from 'expect';
 
 import { Constants } from '../../src/utils/Constants';
@@ -7,6 +8,7 @@ import {
   convertToDate,
   convertToFloat,
   convertToInt,
+  formatDurationMilliSeconds,
   generateUUID,
   getRandomFloat,
   getRandomInteger,
@@ -48,6 +50,12 @@ describe('Utils test suite', () => {
     expect(end - start).toBeGreaterThanOrEqual(1000);
   });
 
+  it('Verify formatDurationMilliSeconds()', () => {
+    expect(formatDurationMilliSeconds(0)).toBe('');
+    expect(formatDurationMilliSeconds(1000)).toBe('1 second');
+    expect(formatDurationMilliSeconds(hoursToMilliseconds(4380))).toBe('182 days 12 hours');
+  });
+
   it('Verify isValidDate()', () => {
     expect(isValidDate(undefined)).toBe(false);
     expect(isValidDate(null)).toBe(false);