]> BookStack Code Mirror - bookstack/commitdiff
Lexical: Fixed details tests 5775/head
authorDan Brown <redacted>
Thu, 28 Aug 2025 10:17:18 +0000 (11:17 +0100)
committerDan Brown <redacted>
Thu, 28 Aug 2025 10:17:18 +0000 (11:17 +0100)
Updated to use new test pattern while there.

resources/js/wysiwyg/lexical/rich-text/__tests__/unit/LexicalDetailsNode.test.ts

index faa31d8874df6f70d481c0f58b720717e95bc048..828aad8393844bba51e9fdbafe917a139054e7cd 100644 (file)
@@ -1,6 +1,5 @@
-import {dispatchKeydownEventForNode, initializeUnitTest} from "lexical/__tests__/utils";
-import {$createDetailsNode, DetailsNode} from "@lexical/rich-text/LexicalDetailsNode";
-import {$createParagraphNode, $getRoot, LexicalNode, ParagraphNode} from "lexical";
+import {createTestContext} from "lexical/__tests__/utils";
+import {$createDetailsNode} from "@lexical/rich-text/LexicalDetailsNode";
 
 const editorConfig = Object.freeze({
     namespace: '',
@@ -9,32 +8,28 @@ const editorConfig = Object.freeze({
 });
 
 describe('LexicalDetailsNode tests', () => {
-    initializeUnitTest((testEnv) => {
+    test('createDOM()', () => {
+        const {editor} = createTestContext();
+        let html!: string;
 
-        test('createDOM()', () => {
-            const {editor} = testEnv;
-            let html!: string;
-
-            editor.updateAndCommit(() => {
-                const details = $createDetailsNode();
-                html = details.createDOM(editorConfig, editor).outerHTML;
-            });
-
-            expect(html).toBe(`<details><summary contenteditable="false"></summary></details>`);
+        editor.updateAndCommit(() => {
+            const details = $createDetailsNode();
+            html = details.createDOM(editorConfig, editor).outerHTML;
         });
 
-        test('exportDOM()', () => {
-            const {editor} = testEnv;
-            let html!: string;
+        expect(html).toBe(`<details contenteditable="false"><summary contenteditable="false"></summary></details>`);
+    });
 
-            editor.updateAndCommit(() => {
-                const details = $createDetailsNode();
-                html = (details.exportDOM(editor).element as HTMLElement).outerHTML;
-            });
+    test('exportDOM()', () => {
+        const {editor} = createTestContext();
+        let html!: string;
 
-            expect(html).toBe(`<details><summary></summary></details>`);
+        editor.updateAndCommit(() => {
+            const details = $createDetailsNode();
+            details.setSummary('Hello there<>!')
+            html = (details.exportDOM(editor).element as HTMLElement).outerHTML;
         });
 
-
+        expect(html).toBe(`<details><summary>Hello there&lt;&gt;!</summary></details>`);
     });
 })
\ No newline at end of file