import assert from "node:assert/strict";
import test from "node:test";
import { STUB_CARRIERS, stubDecision } from "@/lib/mortgage/decisionStub";
import { emptyProfile } from "@/lib/mortgage/schema";

test("stubDecision none reported si_level", () => {
  const d = stubDecision({ ...emptyProfile(), bmi_computed: 28, diseases_none_reported: true });
  assert.equal(d?.offer_family, "si_level");
  assert.ok(d?.reasons.some((r) => /No disease/i.test(r)));
});

test("stubDecision high BMI is gi", () => {
  const d = stubDecision({ ...emptyProfile(), bmi_computed: 50 });
  assert.equal(d?.offer_family, "gi");
});

test("stubDecision hard impairment is graded", () => {
  const d = stubDecision({
    ...emptyProfile(),
    bmi_computed: 30,
    impairments: [{ module: "kidney", attributes: { dialysis: true } }],
  });
  assert.equal(d?.offer_family, "graded");
});

test("stubDecision BMI 43 is graded", () => {
  const d = stubDecision({ ...emptyProfile(), bmi_computed: 43 });
  assert.equal(d?.offer_family, "graded");
});

test("stubDecision empty reasons fallback", () => {
  const d = stubDecision(emptyProfile());
  assert.equal(d?.offer_family, "si_level");
  assert.ok(d?.reasons.length);
});

test("STUB_CARRIERS has two paths", () => {
  assert.equal(STUB_CARRIERS.length, 2);
});
