import test from "node:test";
import assert from "node:assert/strict";
import { connectionStatusKey } from "./connection-status.js";

test("connection status prioritizes phone offline and recovery", () => {
  assert.equal(connectionStatusKey({ connectivityState: "offline", appError: "pc_unreachable", usageError: "account_login_required" }), "connection.deviceOffline");
  assert.equal(connectionStatusKey({ connectivityState: "recovering", appError: "pc_unreachable" }), "connection.recovering");
});

test("connection status distinguishes PC reachability and Codex login", () => {
  assert.equal(connectionStatusKey({ connectivityState: "online", appError: "pc_unreachable" }), "connection.pcUnreachable");
  assert.equal(connectionStatusKey({ connectivityState: "online", usageError: "account_login_required" }), "connection.codexLoginRequired");
  assert.equal(connectionStatusKey({ connectivityState: "online", appError: "context_unavailable" }), "");
});
