import { describe, expect, it } from "vitest";
import { resolveStartupSessionId } from "../src/dimsdk/cli/dimsdk-app.ts";

describe("dimsdk startup session id", () => {
  it("does not create a new session id when none is requested", async () => {
    const id = await resolveStartupSessionId({ envSessionId: undefined });
    expect(id).toBeUndefined();
  });

  it("honors explicit env session id", async () => {
    const id = await resolveStartupSessionId({ envSessionId: "keep" });
    expect(id).toBe("keep");
  });

  it("passes through an arbitrary explicit env session id", async () => {
    const id = await resolveStartupSessionId({ envSessionId: "missing" });
    expect(id).toBe("missing");
  });

  it("trims explicit env session id", async () => {
    const id = await resolveStartupSessionId({ envSessionId: " keep " });
    expect(id).toBe("keep");
  });
});
