|
1 | | -import {describe, expect, it, test} from '@jest/globals'; |
| 1 | +import { describe, expect, it, test } from "@jest/globals"; |
2 | 2 |
|
3 | | -import {convertTimestampToLocaleTime} from '../src/utils/convert-timestamp-to-locale-time'; |
| 3 | +import { convertTimestampToLocaleTime } from "../src/utils/convert-timestamp-to-locale-time"; |
4 | 4 |
|
5 | | -describe('convertTimestampToLocaleTime', () => { |
6 | | - test( |
7 | | - 'should convert a valid timestamp string to a locale time string', () => { |
8 | | - const timestamp = '2025-03-28T12:00:00Z'; |
9 | | - const result = convertTimestampToLocaleTime(timestamp); |
10 | | - expect(result).toBe('3/28/2025, 8:00:00 AM'); |
11 | | - expect(result.length) |
12 | | - .toBeGreaterThan(0); // Ensures it returns a non-empty string |
13 | | - }); |
| 5 | +describe("convertTimestampToLocaleTime", () => { |
| 6 | + test("should convert a valid timestamp string to a locale time string", () => { |
| 7 | + const timestamp = "2025-03-28T12:00:00Z"; |
| 8 | + const result = convertTimestampToLocaleTime(timestamp); |
| 9 | + expect(result).toBe("3/28/2025, 8:00:00 AM"); |
| 10 | + expect(result.length).toBeGreaterThan(0); // Ensures it returns a non-empty string |
| 11 | + }); |
14 | 12 |
|
15 | | - test( |
16 | | - 'should convert a valid numeric timestamp to a locale time string', |
17 | | - () => { |
18 | | - const timestamp = 1711622400000; // Equivalent to 2025-03-28T12:00:00Z |
19 | | - // in milliseconds |
20 | | - const result = convertTimestampToLocaleTime(timestamp); |
21 | | - expect(result).toBe('3/28/2024, 6:40:00 AM'); |
22 | | - expect(result.length).toBeGreaterThan(0); |
23 | | - }); |
| 13 | + test("should convert a valid numeric timestamp to a locale time string", () => { |
| 14 | + const timestamp = 1711622400000; // Equivalent to 2025-03-28T12:00:00Z |
| 15 | + // in milliseconds |
| 16 | + const result = convertTimestampToLocaleTime(timestamp); |
| 17 | + expect(result).toBe("3/28/2024, 6:40:00 AM"); |
| 18 | + expect(result.length).toBeGreaterThan(0); |
| 19 | + }); |
24 | 20 |
|
25 | | - test('convert to locale time date is different', () => { |
26 | | - const timestamp = '2025-03-28 02:33:02.589Z'; |
| 21 | + test("convert to locale time date is different", () => { |
| 22 | + const timestamp = "2025-03-28 02:33:02.589Z"; |
27 | 23 | const result = convertTimestampToLocaleTime(timestamp); |
28 | | - expect(typeof result).toBe('string'); |
| 24 | + expect(typeof result).toBe("string"); |
29 | 25 | expect(result.length).toBeGreaterThan(0); |
30 | 26 | }); |
31 | 27 |
|
32 | | - test('should return \'Invalid Date\' for an invalid timestamp', () => { |
33 | | - const timestamp = 'invalid'; |
| 28 | + test("should return 'Invalid Date' for an invalid timestamp", () => { |
| 29 | + const timestamp = "invalid"; |
34 | 30 | const result = convertTimestampToLocaleTime(timestamp); |
35 | | - expect(result).toBe('Invalid Date'); |
| 31 | + expect(result).toBe("Invalid Date"); |
36 | 32 | }); |
37 | 33 | }); |
0 commit comments