Files
hyperframes/packages/cli/src/commands/audio.command.test.ts
T
JerraiandJerrai b37db11225 feat(cli): audio --read --layer reads a one-layer file whole, no separation (#7345)
* feat(cli): audio --read --layer music|sfx|voice reads a one-layer file whole

A caller that knows a file holds a single layer can declare it: the file is
read whole as that layer with no stem separation and nothing uploaded.
Without the flag the read is unchanged. An unknown layer is rejected.

Consumer: heygen-com/experiment-framework#66322. Proposal OK'd by Rory
(C0BEH487Q7R, 2026-11-07).

Co-Authored-By: Jerrai

* chore(cli): drop added comments from audio read layer

Co-Authored-By: Jerrai
2026-11-07 03:25:46 +00:00

40 lines
1.5 KiB
TypeScript

import { runCommand } from "citty";
import { beforeEach, describe, expect, it, vi } from "vitest";
const { readAudio } = vi.hoisted(() => ({ readAudio: vi.fn() }));
vi.mock("../audio/read/read.js", () => ({ readAudio }));
import audioCommand from "./audio.js";
describe("audio --read --layer", () => {
beforeEach(() => {
readAudio.mockReset();
readAudio.mockResolvedValue({ analysis: {}, textPath: "x.txt", jsonPath: "x.json" });
vi.spyOn(console, "log").mockImplementation(() => {});
});
it.each(["music", "sfx", "voice"])("passes --layer %s to the read", async (layer) => {
await runCommand(audioCommand, { rawArgs: ["a.wav", "--read", "--layer", layer, "--json"] });
expect(readAudio.mock.calls[0]![2]).toMatchObject({ layer });
});
it("passes no layer when the flag is absent", async () => {
await runCommand(audioCommand, { rawArgs: ["a.wav", "--read", "--json"] });
expect(readAudio.mock.calls[0]![2].layer).toBeUndefined();
});
it("rejects an unknown layer and names the valid ones", async () => {
await expect(
runCommand(audioCommand, { rawArgs: ["a.wav", "--read", "--layer", "drums"] }),
).rejects.toThrow("--layer is music, sfx, voice; got drums");
expect(readAudio).not.toHaveBeenCalled();
});
it("rejects --layer without --read", async () => {
await expect(
runCommand(audioCommand, { rawArgs: ["a.wav", "--layer", "music"] }),
).rejects.toThrow("--layer only works with --read");
});
});