import { expect, test } from "bun:test"; import { beepInterval, beepPitch, makeBeeper } from "../static/beep.js"; test("the spike beeps faster as the fuse burns down", () => { expect(beepInterval(45)).toBeGreaterThan(beepInterval(20)); expect(beepInterval(20)).toBeGreaterThan(beepInterval(5)); expect(beepInterval(1)).toBeGreaterThanOrEqual(0.12); expect(beepInterval(45)).toBeLessThanOrEqual(1); }); test("a spent fuse does not beep at all", () => { expect(beepInterval(0)).toBe(0); }); test("and it rises in pitch on the way", () => { expect(beepPitch(2)).toBeGreaterThan(beepPitch(40)); }); test("nothing is played before the browser has had a gesture", () => { const beeper = makeBeeper(); // No AudioContext in this runtime: update must be a no-op, not a throw. expect(() => beeper.update(true, 30, 1)).not.toThrow(); expect(() => beeper.wake()).not.toThrow(); });