Files
codex/codex-cli/tests/extract-image-paths.test.ts
Eason Goodale 5481bf0cb4 update
2025-04-30 11:45:29 -07:00

26 lines
771 B
TypeScript

import { describe, expect, it } from "vitest";
import { extractImagePaths } from "../src/utils/image-detector.js";
describe("extractImagePaths", () => {
it("detects markdown image", () => {
const { paths, text } = extractImagePaths(
"hello ![alt](foo/bar.png) world",
);
expect(paths).toEqual(["foo/bar.png"]);
expect(text).toBe("hello world");
});
it("detects quoted image", () => {
const { paths, text } = extractImagePaths('drag "baz.jpg" here');
expect(paths).toEqual(["baz.jpg"]);
expect(text).toBe("drag here");
});
it("detects bare path", () => {
const { paths, text } = extractImagePaths("see /tmp/img.gif please");
expect(paths).toEqual(["/tmp/img.gif"]);
expect(text).toBe("see please");
});
});