import { describe, expect, test } from "bun:test";
import { followUpsDifferByParty } from "./fristenrechner-wizard";

describe("followUpsDifferByParty — R5 trigger condition (S4, design §3.2)", () => {
  test("true when both claimant and defendant rules present", () => {
    expect(followUpsDifferByParty([
      { primary_party: "claimant" },
      { primary_party: "defendant" },
    ])).toBe(true);
  });
  test("false when all claimant", () => {
    expect(followUpsDifferByParty([
      { primary_party: "claimant" },
      { primary_party: "claimant" },
    ])).toBe(false);
  });
  test("false when all defendant", () => {
    expect(followUpsDifferByParty([
      { primary_party: "defendant" },
    ])).toBe(false);
  });
  test("false when only 'both' rules", () => {
    // "Both" rules are bilateral procedural moves (Vertraulichkeits-
    // Erwiderung); they don't gate R5 because either party can be
    // looking at them.
    expect(followUpsDifferByParty([
      { primary_party: "both" },
      { primary_party: "both" },
    ])).toBe(false);
  });
  test("false when only court rules", () => {
    expect(followUpsDifferByParty([
      { primary_party: "court" },
    ])).toBe(false);
  });
  test("true when mixed with both / court alongside the asymmetric pair", () => {
    expect(followUpsDifferByParty([
      { primary_party: "both" },
      { primary_party: "claimant" },
      { primary_party: "court" },
      { primary_party: "defendant" },
    ])).toBe(true);
  });
  test("false on empty list", () => {
    expect(followUpsDifferByParty([])).toBe(false);
  });
});
