Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fix three failing editor tests

Ammar Ahmed0a09ad590bf4
diff --git a/packages/editor/src/extensions/check-list-item/__tests__/check-list-item.test.ts b/packages/editor/src/extensions/check-list-item/__tests__/check-list-item.test.ts
index 738837033..8e3b98abd 100644
--- a/packages/editor/src/extensions/check-list-item/__tests__/check-list-item.test.ts
+++ b/packages/editor/src/extensions/check-list-item/__tests__/check-list-item.test.ts
@@ -21,7 +21,6 @@ import { describe, expect, test } from "vitest";
import {
createEditor,
h,
- p,
checkList,
checkListItem
} from "../../../../test-utils/index.js";
@@ -36,7 +35,7 @@ describe("check list item", () => {
*/
test("inline image as first child in check list item", async () => {
const el = checkList(
- checkListItem([p(["item 1"])]),
+ checkListItem(["item 1"]),
checkListItem([h("img", [], { src: "image.png" })])
);
diff --git a/packages/editor/src/extensions/image/tests/image.test.ts b/packages/editor/src/extensions/image/tests/image.test.ts
index 0f328a832..0340cd6a0 100644
--- a/packages/editor/src/extensions/image/tests/image.test.ts
+++ b/packages/editor/src/extensions/image/tests/image.test.ts
@@ -55,17 +55,19 @@ test("copy image to clipboard when Ctrl+C is pressed on selected image", async (
const editorElement = h("div");
const { editor } = createEditor({
element: editorElement,
+ // the image is put there as content rather than with `insertImage`, which
+ // needs the attachment extension: what is under test is the copying
+ initialContent: h("img", [], {
+ src: "test.png",
+ "data-hash": testHash,
+ "data-mime": "image/png",
+ "data-filename": "test.png"
+ }).outerHTML,
extensions: {
image: ImageNode
}
});
editor.storage.getAttachmentData = vi.fn().mockResolvedValue(mockImageData);
- editor.commands.insertImage({
- src: "test.png",
- hash: testHash,
- mime: "image/png",
- filename: "test.png"
- });
editor.commands.setNodeSelection(0);
expect(editor.isActive("image")).toBe(true);
diff --git a/packages/editor/src/extensions/task-item/__tests__/task-item.test.ts b/packages/editor/src/extensions/task-item/__tests__/task-item.test.ts
index c9300c8ff..a7f6f97f1 100644
--- a/packages/editor/src/extensions/task-item/__tests__/task-item.test.ts
+++ b/packages/editor/src/extensions/task-item/__tests__/task-item.test.ts
@@ -21,7 +21,6 @@ import { describe, expect, test } from "vitest";
import {
createEditor,
h,
- p,
taskList,
taskItem
} from "../../../../test-utils/index.js";
@@ -36,7 +35,7 @@ describe("task list item", () => {
*/
test("inline image as first child in task list item", async () => {
const el = taskList(
- taskItem([p(["item 1"])]),
+ taskItem(["item 1"]),
taskItem([h("img", [], { src: "image.png" })])
);