import { describe, it, expect, vi, beforeEach } from "vitest"; import { invoke } from "@tauri-apps/api/core"; import { commands } from "$lib/api/bindings"; vi.mock("@tauri-apps/api/core"); // TRACES: UR-040 | DR-052 | UT-061 // // Guards the Tauri v2 camelCase param rule for the background-audio commands: // the command NAME stays snake_case; params are camelCase. describe("background-audio player commands (param naming)", () => { beforeEach(() => { vi.clearAllMocks(); }); it("player_enter_background_audio sends item + positionSeconds (camelCase)", async () => { (invoke as any).mockResolvedValueOnce({}); const item = { id: "vid-1", title: "Episode 1", streamUrl: "https://server/Audio/vid-1/universal?AudioStreamIndex=1", videoCodec: "aac", needsTranscoding: false, }; await commands.playerEnterBackgroundAudio(item, 193); expect(invoke).toHaveBeenCalledWith("player_enter_background_audio", { item, positionSeconds: 193, }); }); it("player_exit_background_audio takes no params and returns a position", async () => { (invoke as any).mockResolvedValueOnce(193.5); const pos = await commands.playerExitBackgroundAudio(); expect(pos).toBe(193.5); expect(invoke).toHaveBeenCalledWith("player_exit_background_audio"); }); });