Quellcode durchsuchen

implementing Mgrdich's suggestion

Mihai vor 1 Jahr
Ursprung
Commit
23d937a94c
1 geänderte Dateien mit 6 neuen und 14 gelöschten Zeilen
  1. 6 14
      kafka-ui-react-app/src/lib/hooks/__tests__/dateTimeHelpers.spec.ts

+ 6 - 14
kafka-ui-react-app/src/lib/hooks/__tests__/dateTimeHelpers.spec.ts

@@ -12,20 +12,12 @@ describe('dateTimeHelpers', () => {
 
     it('should output the correct date', () => {
       const date = new Date();
-      const formattedDate = formatTimestamp(date);
-      const formattedTimestamp = formatTimestamp(date.getTime());
-
-      const expected = `${
-        date.getMonth() + 1
-      }/${date.getDate()}/${date.getFullYear()}, ${date
-        .getHours()
-        .toString()
-        .padStart(2, '0')}:${date
-        .getMinutes()
-        .toString()
-        .padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`;
-      expect(formattedDate).toBe(expected);
-      expect(formattedTimestamp).toBe(expected);
+      expect(formatTimestamp(date)).toBe(
+        date.toLocaleString([], { hourCycle: 'h23' })
+      );
+      expect(formatTimestamp(date.getTime())).toBe(
+        date.toLocaleString([], { hourCycle: 'h23' })
+      );
     });
   });
 });