import test from "node:test";
import assert from "node:assert/strict";
import { NOTIFICATION_TYPES, notificationClickAction, notificationPriority, notificationRowTone, notificationTitle } from "./notification-types.js";

test("notification types define current alert metadata", () => {
  assert.deepEqual(Object.keys(NOTIFICATION_TYPES), ["approval", "completed", "failed", "interrupted", "usage-critical", "usage-exhausted", "usage-low", "weekly-reset"]);
  assert.equal(notificationTitle("approval"), "Approval needed");
  assert.equal(notificationTitle("completed"), "Response complete");
  assert.equal(notificationTitle("failed"), "Work failed");
  assert.equal(notificationTitle("interrupted"), "Work stopped");
  assert.equal(notificationTitle("usage-critical"), "Usage critical");
  assert.equal(notificationTitle("usage-exhausted"), "Usage exhausted");
  assert.equal(notificationTitle("usage-low"), "Usage low");
  assert.equal(notificationTitle("weekly-reset"), "Weekly usage reset");
  assert.equal(notificationPriority("approval") > notificationPriority("completed"), true);
  assert.equal(notificationPriority("usage-critical") > notificationPriority("usage-low"), true);
  assert.equal(notificationPriority("usage-exhausted") > notificationPriority("failed"), true);
  assert.equal(notificationClickAction("completed"), "open-session");
  assert.equal(notificationClickAction("failed"), "open-session");
  assert.equal(notificationClickAction("usage-critical"), "dismiss");
  assert.equal(notificationClickAction("usage-exhausted"), "open-session");
  assert.equal(notificationClickAction("weekly-reset"), "dismiss");
  assert.equal(notificationRowTone("completed"), "notification");
  assert.equal(notificationRowTone("usage-exhausted"), "notification");
  assert.equal(notificationRowTone("usage-low"), "");
  assert.equal(notificationRowTone("weekly-reset"), "");
});

test("unknown notification types use safe defaults", () => {
  assert.equal(notificationTitle("missing"), "Notifications");
  assert.equal(notificationPriority("missing"), 0);
  assert.equal(notificationClickAction("missing"), "dismiss");
  assert.equal(notificationRowTone("missing"), "");
});
