mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-09-09 06:29:32 +03:00
Lexical: Fixed details tests
Updated to use new test pattern while there.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import {dispatchKeydownEventForNode, initializeUnitTest} from "lexical/__tests__/utils";
|
import {createTestContext} from "lexical/__tests__/utils";
|
||||||
import {$createDetailsNode, DetailsNode} from "@lexical/rich-text/LexicalDetailsNode";
|
import {$createDetailsNode} from "@lexical/rich-text/LexicalDetailsNode";
|
||||||
import {$createParagraphNode, $getRoot, LexicalNode, ParagraphNode} from "lexical";
|
|
||||||
|
|
||||||
const editorConfig = Object.freeze({
|
const editorConfig = Object.freeze({
|
||||||
namespace: '',
|
namespace: '',
|
||||||
@@ -9,10 +8,8 @@ const editorConfig = Object.freeze({
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('LexicalDetailsNode tests', () => {
|
describe('LexicalDetailsNode tests', () => {
|
||||||
initializeUnitTest((testEnv) => {
|
|
||||||
|
|
||||||
test('createDOM()', () => {
|
test('createDOM()', () => {
|
||||||
const {editor} = testEnv;
|
const {editor} = createTestContext();
|
||||||
let html!: string;
|
let html!: string;
|
||||||
|
|
||||||
editor.updateAndCommit(() => {
|
editor.updateAndCommit(() => {
|
||||||
@@ -20,21 +17,19 @@ describe('LexicalDetailsNode tests', () => {
|
|||||||
html = details.createDOM(editorConfig, editor).outerHTML;
|
html = details.createDOM(editorConfig, editor).outerHTML;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(html).toBe(`<details><summary contenteditable="false"></summary></details>`);
|
expect(html).toBe(`<details contenteditable="false"><summary contenteditable="false"></summary></details>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exportDOM()', () => {
|
test('exportDOM()', () => {
|
||||||
const {editor} = testEnv;
|
const {editor} = createTestContext();
|
||||||
let html!: string;
|
let html!: string;
|
||||||
|
|
||||||
editor.updateAndCommit(() => {
|
editor.updateAndCommit(() => {
|
||||||
const details = $createDetailsNode();
|
const details = $createDetailsNode();
|
||||||
|
details.setSummary('Hello there<>!')
|
||||||
html = (details.exportDOM(editor).element as HTMLElement).outerHTML;
|
html = (details.exportDOM(editor).element as HTMLElement).outerHTML;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(html).toBe(`<details><summary></summary></details>`);
|
expect(html).toBe(`<details><summary>Hello there<>!</summary></details>`);
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
Reference in New Issue
Block a user