import assert from "node:assert/strict";
import test from "node:test";

import { mapApiMeetingToCalendarRow } from "./meeting-calendar-data";
import * as meetingCalendarData from "./meeting-calendar-data";

test("maps the active meeting summary id into the calendar row", () => {
  const row = mapApiMeetingToCalendarRow({
    id: 7,
    title: "Calendar meeting",
    meetingSummaryId: 21,
  });

  assert.equal(row.meetingSummaryId, 21);
});

test("uses the existing summary action when the meeting already has one", () => {
  const getAction = (
    meetingCalendarData as unknown as {
      getMeetingSummaryAction?: (meetingSummaryId: number | null) => {
        label: string;
        path: string;
      };
    }
  ).getMeetingSummaryAction;

  assert.equal(typeof getAction, "function");
  assert.deepEqual(getAction?.(21), {
    label: "View Meeting Summary",
    path: "/ministry/meeting-summary/21",
  });
  assert.deepEqual(getAction?.(null), {
    label: "Create Meeting Summary",
    path: null,
  });
});
