How to represent an empty list item / TODO list item in unit test #2603
Answered
by
OliverWales
OliverWales
asked this question in
Q&A
-
I'm writing a unit test to test the behaviour I'm expecting in #2596. This requires me to emulate pressing backspace in a node following an empty list item node. I've tried variations of the following: const input = (
<editor>
<hul>
<hli>
<hlic>
<hp></hp>
</hlic>
</hli>
</hul>
<hp>
<cursor />
two
</hp>
</editor>
) as any as PlateEditor;
const expected = (
<editor>
<hul>
<hli>
<hlic>two</hlic>
</hli>
</hul>
</editor>
) as any as PlateEditor;
const editor = createPlateEditor({
editor: input,
plugins: [createListPlugin()],
});
editor.deleteBackward('character');
expect(editor.children).toEqual(expected.children); But running it causes a crash with the message "Cannot get the start point in the node at path [] because it has no start text node." What am I doing wrong? How can I emulate the behaviour demonstrated in the issue? |
Beta Was this translation helpful? Give feedback.
Answered by
OliverWales
Sep 5, 2023
Replies: 1 comment
-
Managed to fix it by using const input = (
<editor>
<hul>
<hli>
<hlic>
<htext />
</hlic>
</hli>
</hul>
<hp>
<cursor />
two
</hp>
</editor>
) as any as PlateEditor; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
OliverWales
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Managed to fix it by using
<htext />
, input: