import { describe, expect, it } from "vitest";
import { resolveEffectiveConnectorIds } from "./connector_selection";

describe("resolveEffectiveConnectorIds", () => {
  it("falls back to the chat defaults when the turn does not specify any connectors", () => {
    expect(
      resolveEffectiveConnectorIds({
        chatConnectorIds: [3, 1, 1],
        requestConnectorIds: [],
      }),
    ).toEqual([3, 1]);
  });

  it("appends temporary turn connectors by default", () => {
    expect(
      resolveEffectiveConnectorIds({
        chatConnectorIds: [1, 2],
        requestConnectorIds: [2, 5],
        requestSelectionMode: "append",
      }),
    ).toEqual([1, 2, 5]);
  });

  it("replaces the chat defaults when the turn requests replace mode", () => {
    expect(
      resolveEffectiveConnectorIds({
        chatConnectorIds: [1, 2],
        requestConnectorIds: [4, 4, 9],
        requestSelectionMode: "replace",
      }),
    ).toEqual([4, 9]);
  });
});
