Text-note card menus can copy the note as rich text. The open note uses the editor, including unsaved changes; other notes copy saved content without switching the editor.
25 lines
1.4 KiB
TypeScript
25 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const readSource = (path: string) => readFileSync(new URL(path, import.meta.url), "utf8");
|
|
|
|
const memoListSource = readSource("../apps/web/src/components/MemoListPane.tsx");
|
|
const workspaceSource = readSource("../apps/web/src/components/WorkspaceApp.tsx");
|
|
const editorActionsSource = readSource("../apps/web/src/components/editor/useEditorDocumentActions.ts");
|
|
|
|
describe("memo list WeChat copy", () => {
|
|
test("adds the publish copy action to text-note card menus", () => {
|
|
expect(memoListSource).toContain('t("editor.copyToWeChat")');
|
|
expect(memoListSource).toContain("!memoContextMenu.memo.diagramKind && !memoContextMenu.memo.structuredTable && !memoContextMenu.memo.infographic");
|
|
expect(memoListSource).toContain("void handleCopyContextMemoToWeChat()");
|
|
expect(memoListSource).toContain('wechatCopyNotice === "copied" ? "editor.copiedToWeChat" : "editor.copyToWeChatFailed"');
|
|
});
|
|
|
|
test("copies the open text note through the editor and other notes from saved markdown", () => {
|
|
expect(workspaceSource).toContain('action: "copy-wechat"');
|
|
expect(workspaceSource).toContain("copyMarkdownToWeChat(memo.contentMarkdown)");
|
|
expect(workspaceSource).toContain("return \"editor\"");
|
|
expect(editorActionsSource).toContain("copyWeChat: () => void handleCopyToWeChat()");
|
|
});
|
|
});
|