Home Manual Reference Source Test

tests/step1parts.test.js

  1. import { describe, it, expect } from "vitest";
  2. import { INSTANCES } from "./api.js";
  3. const { step1 } = INSTANCES;
  4. /** @test {Step1Parts} */
  5. describe("Step1Parts", () => {
  6. /** @test {Step1Parts#schema} */
  7. it("schema yields parts, tempo and part with sane defaults; renders BPM markup via tempo.format", () => {
  8. const params = step1.schema();
  9. const parts = params.find((p) => p.name === "parts");
  10. expect(parts).toMatchObject({ default: 1, min: 1, max: 5 });
  11. const tempo = params.find((p) => p.name === "tempo");
  12. expect(tempo).toMatchObject({ default: 120, min: 30, max: 210 });
  13. expect(tempo.format(120)).toContain("120");
  14. expect(tempo.format(120)).toContain("BPM");
  15. const part = params.find((p) => p.name === "part");
  16. expect(part.type).toBe("nested");
  17. expect(part.defaults).toHaveLength(5);
  18. expect(part.defaults.find((d) => d.label === "B").bars).toBe(5);
  19. expect(part.defaults.find((d) => d.label === "C").bars).toBe(6);
  20. expect(part.defaults.find((d) => d.label === "A").bars).toBe(4);
  21. });
  22. });