Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/webview/image/cm-image-widget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,34 @@ describe("ImageBlockWidget identity + events", () => {
errSpy.mockRestore();
}
});

// A fresh toDOM'd widget's click must hit the `blockStart` entry written in
// toDOM, not the listener's miss fallback — the absent `console.error` is the
// only observable difference. The anchor VALUE cannot distinguish them here
// (nor in any other fixture in this file, which all click in the same breath
// as toDOM): both trace back to the same `docFrom` constructor argument, so
// deleting `blockStart.set(root, this.docFrom)` in `toDOM` leaves every such
// anchor assertion green. (The updateDOM re-stamp fixtures below stay green
// for an unrelated reason: their OWN `blockStart.set` write re-fills the
// entry with the new docFrom.) Mirrors the table widget's pin of the same
// gap.
it("does not log a blockStart miss when a fresh toDOM'd widget is clicked", () => {
const errSpy = vi.spyOn(console, "error").mockImplementation(() => {});
try {
const { view, dispatched } = recordingView();
const dom = new ImageBlockWidget(
"a",
url("https://x.test/a.png"),
"![a](https://x.test/a.png)",
42
).toDOM(view);
dom.click();
expect(dispatched).toEqual([{ anchor: 42 }]);
expect(errSpy).not.toHaveBeenCalled();
} finally {
errSpy.mockRestore();
}
});
});

describe("ImageBlockWidget.toDOM — dimension cache", () => {
Expand Down
Loading