Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

1.1 KB
Raw Blame
import { describe, expect, it } from "vite-plus/test";

import { beginForegroundHandoff, isForegroundHandoffActive } from "./foreground-handoff";

describe("foreground handoff", () => {
  it("is active only while a handoff is open", () => {
    expect(isForegroundHandoffActive()).toBe(false);
    const end = beginForegroundHandoff();
    expect(isForegroundHandoffActive()).toBe(true);
    end();
    expect(isForegroundHandoffActive()).toBe(false);
  });

  it("stays active until every overlapping handoff ends", () => {
    const endFirst = beginForegroundHandoff();
    const endSecond = beginForegroundHandoff();
    endFirst();
    expect(isForegroundHandoffActive()).toBe(true);
    endSecond();
    expect(isForegroundHandoffActive()).toBe(false);
  });

  it("tolerates an end function called twice", () => {
    const endFirst = beginForegroundHandoff();
    const endSecond = beginForegroundHandoff();
    endFirst();
    endFirst();
    expect(isForegroundHandoffActive()).toBe(true);
    endSecond();
    expect(isForegroundHandoffActive()).toBe(false);
  });
});