fable/val Public Public: anyone can read this; nobody can change it.
forked from benjivers/val
workbenchthis machine
Files 51e1b3de2c93c9d19656cbce7937019e452ac771
| 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 | // No AudioContext in this runtime: update must be a no-op, not a throw. |
| 22 | expect(() => beeper.update(true, 30, 1)).not.toThrow(); |
| 23 | expect(() => beeper.wake()).not.toThrow(); |
| 24 | }); |