Skip to content

Build your personal knowledge base with Trilium Notes

packages/codemirror: improve test coverage

Adorian Dorand57e52d7516c
diff --git a/packages/codemirror/src/index.spec.ts b/packages/codemirror/src/index.spec.ts
index 37c6ab7f22..d3303a0467 100644
--- a/packages/codemirror/src/index.spec.ts
+++ b/packages/codemirror/src/index.spec.ts
@@ -415,7 +415,10 @@ describe("CodeMirror", () => {
const instance = build();
editor = instance;
instance.setText("ab\ncd");
- instance.dispatch({ selection: EditorSelection.cursor(4, -1) });
+ // A transaction keeps the `assoc` of an `EditorSelection`, not of a bare range.
+ const cursor = EditorSelection.cursor(4, -1);
+ instance.dispatch({ selection: EditorSelection.create([ cursor ]) });
+ expect(instance.state.selection.main).toMatchObject({ head: 4, assoc: -1 });
instance.prepareToLeave();
expect(instance.state.selection.main).toMatchObject({ head: 4, assoc: 0 });