import { describe, expect, it } from "vitest"; import { SpeakerGate } from "../src/core/speakers.js"; describe("SpeakerGate", () => { it("hears up to the limit and lets the next person in once someone stops", () => { const g = new SpeakerGate(2); expect(g.start("a")).toBe(true); expect(g.start("b")).toBe(true); expect(g.start("c")).toBe(false); expect(g.isActive("c")).toBe(false); expect(g.end("a")).toBe(true); expect(g.start("c")).toBe(true); expect(g.count).toBe(2); }); it("a speaker already heard stays heard; ending someone not heard is a no-op", () => { const g = new SpeakerGate(1); expect(g.start("a")).toBe(true); expect(g.start("a")).toBe(true); expect(g.end("z")).toBe(false); expect(g.end("a")).toBe(true); expect(g.end("a")).toBe(false); }); });