Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
choden-dev committed Nov 1, 2024
1 parent 2190ae7 commit 894e466
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions client/src/components/generic/Event/EventUtils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { EventRenderingUtils } from "./EventUtils"

describe("dateTimeLocalPlaceHolder", () => {
it("should return a formatted string in ISO 8601 format without milliseconds", () => {
const date = new Date("2024-11-01T23:34:15.123Z")
const result = EventRenderingUtils.dateTimeLocalPlaceHolder(date)
expect(result).toBe("2024-11-01T23:34:15")
})

it("should handle dates without milliseconds correctly", () => {
const date = new Date("2024-11-01T23:34:15Z")
const result = EventRenderingUtils.dateTimeLocalPlaceHolder(date)
expect(result).toBe("2024-11-01T23:34:15")
})

it("should handle different time zones correctly", () => {
const date = new Date("2024-11-01T23:34:15.123+09:00")
const result = EventRenderingUtils.dateTimeLocalPlaceHolder(date)
expect(result).toBe("2024-11-01T14:34:15")
})

it("should handle leap years correctly", () => {
const date = new Date("2024-02-29T23:34:15.123Z")
const result = EventRenderingUtils.dateTimeLocalPlaceHolder(date)
expect(result).toBe("2024-02-29T23:34:15")
})

it("should handle dates before 1970 correctly", () => {
const date = new Date("1969-12-31T23:34:15.123Z")
const result = EventRenderingUtils.dateTimeLocalPlaceHolder(date)
expect(result).toBe("1969-12-31T23:34:15")
})
})

0 comments on commit 894e466

Please sign in to comment.