AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
import { describe, expect, test } from "bun:test";
import { findMarkdownImagePasteMatches } from "./markdown-image-paste.ts";
describe("findMarkdownImagePasteMatches", () => {
test("maps a pasted Markdown image to Tiptap node attributes", () => {
const markdown = "";
expect(findMarkdownImagePasteMatches(markdown, markdown)).toEqual([{
index: 0,
text: markdown,
data: {
src: "https://example.com/image.webp",
alt: "图片",
title: "预览图",
},
}]);
});
test("finds each image when pasted as separate lines", () => {
const first = "";
const second = "";
const clipboard = `${first}\n${second}`;
expect(findMarkdownImagePasteMatches(first, clipboard)).toHaveLength(1);
expect(findMarkdownImagePasteMatches(second, clipboard)).toEqual([{
index: 0,
text: second,
data: {
src: "https://example.com/second.png",
alt: "second",
title: null,
},
}]);
});
test("does not match mixed text or unsafe image sources", () => {
expect(findMarkdownImagePasteMatches(
"Before ",
"Before ",
)).toEqual([]);
expect(findMarkdownImagePasteMatches(
")",
")",
)).toEqual([]);
});
});