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.
21 lines
1.3 KiB
TypeScript
21 lines
1.3 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { moveMarks, replayMoveMarks } from "../../../src/lib/workspace/treeMoveHistory.ts";
|
|
test("move undo preserves later bookmarks, pins, and new files", () => {
|
|
const before = { pins: ["notes/a.md"], bookmarks: [], order: { notes: ["a.md", "b.md"], archive: [] as string[] } };
|
|
const after = moveMarks(before, "notes/a.md", "archive/a.md");
|
|
const current = { ...after, bookmarks: ["other.md"], pins: [...after.pins, "b.md"], order: { ...after.order, notes: [...after.order.notes, "new.md"] } };
|
|
const undo = replayMoveMarks(current, before, after, [{ from: "notes/a.md", to: "archive/a.md" }], false);
|
|
assert.deepEqual(undo.pins, ["notes/a.md", "b.md"]);
|
|
assert.deepEqual(undo.bookmarks, ["other.md"]);
|
|
assert.deepEqual(undo.order.notes, ["a.md", "b.md", "new.md"]);
|
|
assert.deepEqual(undo.order.archive, []);
|
|
});
|
|
test("folder moves retain nested marks and custom order", () => {
|
|
const marks = { pins: ["old/child.md"], bookmarks: ["old/deep/file.md"], order: { old: ["child.md"], "old/deep": ["file.md"] } };
|
|
const next = moveMarks(marks, "old", "new/old");
|
|
assert.deepEqual(next.pins, ["new/old/child.md"]);
|
|
assert.deepEqual(next.bookmarks, ["new/old/deep/file.md"]);
|
|
assert.deepEqual(next.order["new/old/deep"], ["file.md"]);
|
|
});
|