Files
2026-05-27 23:47:53 +01:00

26 lines
1009 B
TypeScript

import { describe, expect, it } from "@suaveplan/testing/runner";
import { BeatDetector } from "../src/detector/beat-detector.js";
import { makeMetronome } from "./fixtures.js";
describe("integration — full analyse round-trip", () => {
it("recovers BPM across a range of synthetic tempi", {
timeout: 30000,
}, async () => {
for (const bpm of [100, 120, 140]) {
const doc = makeMetronome({ bpm, durationSeconds: 6 });
const r = await new BeatDetector().analyze(doc);
expect(r.bpm).toBeGreaterThanOrEqual(60);
expect(r.bpm).toBeLessThanOrEqual(200);
}
});
it("end-to-end matches independent runs", { timeout: 30000 }, async () => {
const doc = makeMetronome({ bpm: 120, durationSeconds: 6 });
const d = new BeatDetector();
const a = await d.analyze(doc);
const b = await d.analyze(doc);
expect(a.bpm).toBe(b.bpm);
expect(a.beats.length).toBe(b.beats.length);
});
});