diff --git a/packages/lexical-list/src/__tests__/unit/LexicalListNode.test.ts b/packages/lexical-list/src/__tests__/unit/LexicalListNode.test.ts index 6abcbbd4cb7..a7d31d0e9ac 100644 --- a/packages/lexical-list/src/__tests__/unit/LexicalListNode.test.ts +++ b/packages/lexical-list/src/__tests__/unit/LexicalListNode.test.ts @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * */ +import {$isLinkNode, LinkNode} from '@lexical/link'; import {ParagraphNode, TextNode} from 'lexical'; import {initializeUnitTest} from 'lexical/src/__tests__/utils'; @@ -260,6 +261,31 @@ describe('LexicalListNode tests', () => { }); }); + test('ListNode.append() should wrap an InlineNode in a ListItemNode without converting it to TextNode', async () => { + const {editor} = testEnv; + + await editor.update(() => { + const listNode = new ListNode('bullet', 1); + const linkNode = new LinkNode('https://lexical.dev/'); + + listNode.append(linkNode); + + const firstChild = listNode.getFirstChild(); + expect($isListItemNode(firstChild)).toBe(true); + + if ($isListItemNode(firstChild)) { + const wrappedNode = firstChild?.getFirstChild(); + expect($isLinkNode(wrappedNode)).toBe(true); + + expect((wrappedNode as LinkNode).getURL()).toBe( + 'https://lexical.dev/', + ); + } else { + throw new Error('First child is not a ListItemNode'); + } + }); + }); + test('$createListNode()', async () => { const {editor} = testEnv;