2 * Copyright (c) Meta Platforms, Inc. and affiliates.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
10 $isRootTextContentEmpty,
11 $isRootTextContentEmptyCurry,
13 } from '@lexical/text';
14 import {$createParagraphNode, $createTextNode, $getRoot} from 'lexical';
15 import {initializeUnitTest} from 'lexical/__tests__/utils';
17 describe('LexicalRootHelpers tests', () => {
18 initializeUnitTest((testEnv) => {
19 it('textContent', async () => {
20 const editor = testEnv.editor;
22 expect(editor.getEditorState().read($rootTextContent)).toBe('');
24 await editor.update(() => {
25 const root = $getRoot();
26 const paragraph = $createParagraphNode();
27 const text = $createTextNode('foo');
28 root.append(paragraph);
29 paragraph.append(text);
31 expect($rootTextContent()).toBe('foo');
34 expect(editor.getEditorState().read($rootTextContent)).toBe('foo');
37 it('isBlank', async () => {
38 const editor = testEnv.editor;
43 .read($isRootTextContentEmptyCurry(editor.isComposing())),
46 await editor.update(() => {
47 const root = $getRoot();
48 const paragraph = $createParagraphNode();
49 const text = $createTextNode('foo');
50 root.append(paragraph);
51 paragraph.append(text);
53 expect($isRootTextContentEmpty(editor.isComposing())).toBe(false);
59 .read($isRootTextContentEmptyCurry(editor.isComposing())),