Move the tests from scripts/ to tests/ by feature
Unit tests go to tests/unit/<area>/, browser smoke tests to tests/smoke/<area>/, and tests against a running desktop app to tests/native/. Files named after dates, work passes, or Kanban cards get feature names, for example editorOctober12 -> editor/footnotes. scripts/ keeps the build, release, and package tools. Plugin repositories import scripts/packagePlugin.mjs, and the Terminal smoke test imports scripts/pluginMocks.mjs, which now re-exports the harness copy. The unit tests get their own type check (tests/tsconfig.json) with Node types. pnpm check runs it after the app check. Add @types/node and fix the three test mocks that it reported.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import {
|
||||
findMarkdownImages,
|
||||
isImagePath,
|
||||
isRemoteImage,
|
||||
resolveImageRel,
|
||||
} from "../../../src/lib/workspace/media.ts";
|
||||
|
||||
test("image paths are detected by extension", () => {
|
||||
assert.equal(isImagePath("screenshot.png"), true);
|
||||
assert.equal(isImagePath("notes/photo.JPEG"), true);
|
||||
assert.equal(isImagePath("notes/inbox.md"), false);
|
||||
});
|
||||
|
||||
test("markdown image syntax is parsed", () => {
|
||||
const found = findMarkdownImages("See  and ![[screenshot.png|Hero]]");
|
||||
assert.equal(found.length, 2);
|
||||
assert.equal(found[0].src, "../shot.png");
|
||||
assert.equal(found[0].kind, "md");
|
||||
assert.equal(found[1].src, "screenshot.png");
|
||||
assert.equal(found[1].alt, "Hero");
|
||||
assert.equal(found[1].kind, "wiki");
|
||||
});
|
||||
|
||||
test("image paths resolve from the note folder", () => {
|
||||
assert.equal(resolveImageRel("notes/inbox.md", "pic.png"), "notes/pic.png");
|
||||
assert.equal(resolveImageRel("notes/inbox.md", "../screenshot.png"), "screenshot.png");
|
||||
assert.equal(resolveImageRel("notes/inbox.md", "screenshot.png"), "notes/screenshot.png");
|
||||
assert.equal(resolveImageRel("notes/inbox.md", "/assets/pic.png"), "assets/pic.png");
|
||||
});
|
||||
|
||||
test("remote images stay as URLs", () => {
|
||||
assert.equal(isRemoteImage("https://example.com/a.png"), true);
|
||||
assert.equal(isRemoteImage("screenshot.png"), false);
|
||||
});
|
||||
Reference in New Issue
Block a user