| 1 |
import { expect, test } from "bun:test"; |
| 2 |
import { beepInterval, beepPitch, makeBeeper } from "../static/beep.js"; |
| 3 |
|
| 4 |
test("the spike beeps faster as the fuse burns down", () => { |
| 5 |
expect(beepInterval(45)).toBeGreaterThan(beepInterval(20)); |
| 6 |
expect(beepInterval(20)).toBeGreaterThan(beepInterval(5)); |
| 7 |
expect(beepInterval(1)).toBeGreaterThanOrEqual(0.12); |
| 8 |
expect(beepInterval(45)).toBeLessThanOrEqual(1); |
| 9 |
}); |
| 10 |
|
| 11 |
test("a spent fuse does not beep at all", () => { |
| 12 |
expect(beepInterval(0)).toBe(0); |
| 13 |
}); |
| 14 |
|
| 15 |
test("and it rises in pitch on the way", () => { |
| 16 |
expect(beepPitch(2)).toBeGreaterThan(beepPitch(40)); |
| 17 |
}); |
| 18 |
|
| 19 |
test("nothing is played before the browser has had a gesture", () => { |
| 20 |
const beeper = makeBeeper(); |
| 21 |
|
| 22 |
expect(() => beeper.update(true, 30, 1)).not.toThrow(); |
| 23 |
expect(() => beeper.wake()).not.toThrow(); |
| 24 |
}); |