import { assertEquals } from "jsr:@std/assert";
import { resolveIanaName, getUtcOffsetMs } from "./timezones.ts";

Deno.test("resolveIanaName - Windows names", () => {
  assertEquals(resolveIanaName("Eastern Standard Time"), "America/New_York");
  assertEquals(resolveIanaName("Romance Standard Time"), "Europe/Paris");
  assertEquals(resolveIanaName("Pacific Standard Time"), "America/Los_Angeles");
});

Deno.test("resolveIanaName - IANA names (identity)", () => {
  assertEquals(resolveIanaName("America/Chicago"), "America/Chicago");
  assertEquals(resolveIanaName("Europe/London"), "Europe/London");
});

Deno.test("resolveIanaName - UTC and special cases", () => {
  assertEquals(resolveIanaName("UTC"), "UTC");
  assertEquals(resolveIanaName("None"), "UTC");
  assertEquals(resolveIanaName(""), "UTC");
});

Deno.test("resolveIanaName - Unknown names", () => {
  assertEquals(resolveIanaName("Mars Standard Time"), null);
});

Deno.test("getUtcOffsetMs - New York (DST check)", () => {
  const jan = new Date("2025-01-15T12:00:00Z");
  const july = new Date("2025-07-15T12:00:00Z");
  
  // America/New_York is UTC-5 in Winter
  assertEquals(getUtcOffsetMs("America/New_York", jan), -5 * 3600000);
  // America/New_York is UTC-4 in Summer
  assertEquals(getUtcOffsetMs("America/New_York", july), -4 * 3600000);
});

Deno.test("getUtcOffsetMs - Paris (DST check)", () => {
  const jan = new Date("2025-01-15T12:00:00Z");
  const july = new Date("2025-07-15T12:00:00Z");
  
  // Europe/Paris is UTC+1 in Winter
  assertEquals(getUtcOffsetMs("Europe/Paris", jan), 1 * 3600000);
  // Europe/Paris is UTC+2 in Summer
  assertEquals(getUtcOffsetMs("Europe/Paris", july), 2 * 3600000);
});
