Skip to content

Commit f5da310

Browse files
committed
Lexical: Fixed details tests
Updated to use new test pattern while there.
1 parent 46613f7 commit f5da310

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed
Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import {dispatchKeydownEventForNode, initializeUnitTest} from "lexical/__tests__/utils";
2-
import {$createDetailsNode, DetailsNode} from "@lexical/rich-text/LexicalDetailsNode";
3-
import {$createParagraphNode, $getRoot, LexicalNode, ParagraphNode} from "lexical";
1+
import {createTestContext} from "lexical/__tests__/utils";
2+
import {$createDetailsNode} from "@lexical/rich-text/LexicalDetailsNode";
43

54
const editorConfig = Object.freeze({
65
namespace: '',
@@ -9,32 +8,28 @@ const editorConfig = Object.freeze({
98
});
109

1110
describe('LexicalDetailsNode tests', () => {
12-
initializeUnitTest((testEnv) => {
11+
test('createDOM()', () => {
12+
const {editor} = createTestContext();
13+
let html!: string;
1314

14-
test('createDOM()', () => {
15-
const {editor} = testEnv;
16-
let html!: string;
17-
18-
editor.updateAndCommit(() => {
19-
const details = $createDetailsNode();
20-
html = details.createDOM(editorConfig, editor).outerHTML;
21-
});
22-
23-
expect(html).toBe(`<details><summary contenteditable="false"></summary></details>`);
15+
editor.updateAndCommit(() => {
16+
const details = $createDetailsNode();
17+
html = details.createDOM(editorConfig, editor).outerHTML;
2418
});
2519

26-
test('exportDOM()', () => {
27-
const {editor} = testEnv;
28-
let html!: string;
20+
expect(html).toBe(`<details contenteditable="false"><summary contenteditable="false"></summary></details>`);
21+
});
2922

30-
editor.updateAndCommit(() => {
31-
const details = $createDetailsNode();
32-
html = (details.exportDOM(editor).element as HTMLElement).outerHTML;
33-
});
23+
test('exportDOM()', () => {
24+
const {editor} = createTestContext();
25+
let html!: string;
3426

35-
expect(html).toBe(`<details><summary></summary></details>`);
27+
editor.updateAndCommit(() => {
28+
const details = $createDetailsNode();
29+
details.setSummary('Hello there<>!')
30+
html = (details.exportDOM(editor).element as HTMLElement).outerHTML;
3631
});
3732

38-
33+
expect(html).toBe(`<details><summary>Hello there&lt;&gt;!</summary></details>`);
3934
});
4035
})

0 commit comments

Comments
 (0)