import { describe, expect, it } from "vitest";
import { isMSTeamsActivityFromSelf } from "./message-handler.js";

describe("isMSTeamsActivityFromSelf", () => {
  it("recognizes app id and recipient echoes as self-authored", () => {
    expect(
      isMSTeamsActivityFromSelf(
        { from: { id: "bot-app-id" }, recipient: { id: "29:user" } },
        "bot-app-id",
      ),
    ).toBe(true);
    expect(
      isMSTeamsActivityFromSelf(
        { from: { aadObjectId: "bot-app-id" }, recipient: { id: "29:user" } },
        "bot-app-id",
      ),
    ).toBe(true);
    expect(
      isMSTeamsActivityFromSelf(
        { from: { id: "29:bot" }, recipient: { id: "29:bot" } },
        "bot-app-id",
      ),
    ).toBe(true);
  });

  it("does not drop normal user-authored messages", () => {
    expect(
      isMSTeamsActivityFromSelf(
        { from: { id: "29:user", aadObjectId: "user-aad" }, recipient: { id: "29:bot" } },
        "bot-app-id",
      ),
    ).toBe(false);
  });
});
