Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { classifyMarkdownImageSource } from "./markdownImages.js";
4
5describe("classifyMarkdownImageSource", () => {
6 it.each([
7 ["images/result.png", "/workspace/project", "/workspace/project/images/result.png"],
8 [
9 "images\\result.png",
10 "C:\\Users\\dara\\project",
11 "C:\\Users\\dara\\project\\images\\result.png",
12 ],
13 ["file:///workspace/project/image%20one.png", null, "/workspace/project/image one.png"],
14 ["file://server/share/image.png", null, "\\\\server\\share\\image.png"],
15 ])("maps %s to a workspace file", (source, workspaceRoot, path) => {
16 expect(classifyMarkdownImageSource(source, workspaceRoot)).toEqual({
17 _tag: "WorkspaceFile",
18 path,
19 });
20 });
21
22 it.each(["image.png", "javascript:alert(1)", "file://%"])(
23 "blocks unsupported or unresolved source %s",
24 (source) => {
25 expect(classifyMarkdownImageSource(source)).toEqual({ _tag: "Blocked" });
26 },
27 );
28});