sistema-de-chamados/tests/time.test.ts
2025-10-16 19:14:46 -03:00

16 lines
550 B
TypeScript

import { describe, expect, it } from "vitest"
import { dateKeyTZ, isAtHourTZ } from "@/lib/time"
describe("time tz helpers", () => {
it("computes date key in timezone", () => {
const d = new Date("2025-10-07T10:30:00.000Z")
const key = dateKeyTZ(d, "America/Sao_Paulo")
// 2025-10-07 07:30 in Sao Paulo (UTC-3)
expect(key).toBe("2025-10-07")
})
it("matches hour in timezone", () => {
const d = new Date("2025-10-07T11:00:00.000Z") // 08:00 BRT (no DST)
expect(isAtHourTZ(d, "America/Sao_Paulo", 8)).toBe(true)
})
})