|
| 1 | +// @vitest-environment happy-dom |
| 2 | +// Imports the clip-content thumbnail primitives the way a host app does: by package name. |
| 3 | +// Desktop's timeline lane draws audio waveforms and image thumbnails without a deep import. |
| 4 | +import { act } from "react"; |
| 5 | +import { afterEach, describe, expect, it, vi } from "vitest"; |
| 6 | +import { installReactActEnvironment, mountReactHarness } from "./hooks/domSelectionTestHarness"; |
| 7 | + |
| 8 | +const { leaseSpy } = vi.hoisted(() => ({ |
| 9 | + leaseSpy: vi.fn((_request: unknown) => ({ status: "loading" as const })), |
| 10 | +})); |
| 11 | + |
| 12 | +vi.mock("./hooks/useThumbnailLease", () => ({ |
| 13 | + useThumbnailLease: leaseSpy, |
| 14 | +})); |
| 15 | + |
| 16 | +import { AudioWaveform, ImageThumbnail, useRenderClipContent } from "@hyperframes/studio"; |
| 17 | + |
| 18 | +installReactActEnvironment(); |
| 19 | + |
| 20 | +afterEach(() => { |
| 21 | + leaseSpy.mockClear(); |
| 22 | + document.body.innerHTML = ""; |
| 23 | +}); |
| 24 | + |
| 25 | +describe("clip content package exports", () => { |
| 26 | + it("mounts AudioWaveform and leases waveform decoding", async () => { |
| 27 | + const root = mountReactHarness( |
| 28 | + <AudioWaveform |
| 29 | + audioUrl="/media/voice.wav" |
| 30 | + label="" |
| 31 | + labelColor="#fff" |
| 32 | + projectId="project-a" |
| 33 | + sessionEpoch={9} |
| 34 | + priority="interaction" |
| 35 | + />, |
| 36 | + ); |
| 37 | + |
| 38 | + expect(leaseSpy).toHaveBeenCalledWith(expect.objectContaining({ kind: "waveform" })); |
| 39 | + await act(async () => root.unmount()); |
| 40 | + }); |
| 41 | + |
| 42 | + it("mounts ImageThumbnail and leases the still frame", async () => { |
| 43 | + const root = mountReactHarness( |
| 44 | + <ImageThumbnail imageSrc="/media/frame.png" label="" labelColor="#fff" />, |
| 45 | + ); |
| 46 | + |
| 47 | + expect(leaseSpy).toHaveBeenCalledWith(expect.objectContaining({ kind: "image" })); |
| 48 | + await act(async () => root.unmount()); |
| 49 | + }); |
| 50 | + |
| 51 | + it("exposes useRenderClipContent as a hook a host can call", () => { |
| 52 | + expect(typeof useRenderClipContent).toBe("function"); |
| 53 | + }); |
| 54 | +}); |
0 commit comments