import { render } from "@testing-library/react"; import { createRef } from "react"; import { describe, expect, it, vi } from "vitest"; import Editor from "@/components/MemoEditor/Editor"; import type { EditorController } from "@/components/MemoEditor/types/editorController"; vi.mock("@/hooks/useUserQueries", () => ({ useTagCounts: () => ({ data: {} }), })); describe("Editor", () => { it("loads markdown and serializes it back verbatim", () => { const ref = createRef(); render( , ); expect(ref.current?.getMarkdown()).toBe("# Title\n\n- a\n 1. b"); }); it("emits changes through onContentChange", () => { const ref = createRef(); const onChange = vi.fn(); render(); ref.current?.setMarkdown("hello"); expect(onChange).toHaveBeenCalledWith("hello"); }); });