Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

865 B
Raw Blame
import { describe, expect, it } from "vitest";

import { personKey } from "../person-key.ts";
import { lookedAfterBy } from "./looked-after.ts";

const ADA = "[email protected]";
const names: Record<string, string> = { [personKey({ id: "", email: ADA })]: "Ada Lovelace" };

describe("who looks after a team bot, by name", () => {
  it("names the member the bot reports to, from their team profile, else from their address", () => {
    expect(lookedAfterBy({ reportsTo: ADA, createdBy: "[email protected]" }, (person) => names[person])).toBe("Ada Lovelace");
    expect(lookedAfterBy({ createdBy: "[email protected]" }, (person) => names[person])).toBe("Ben Ray");
    expect(lookedAfterBy({ createdBy: ADA }, () => ADA)).toBe("Ada");
  });

  it("names nobody for a bot nobody owns", () => {
    expect(lookedAfterBy({}, (person) => names[person])).toBeNull();
  });
});