Skip to content

Commit f5bc89b

Browse files
committed
test(editor): add more tests
1 parent 7b5fec7 commit f5bc89b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/editor/__tests__/create.test.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import { createEditor, createToolbar } from '../../../packages/editor/src/index'
77
import { ICreateEditorOption, ICreateToolbarOption } from '../../../packages/editor/src/create'
8+
import { DOMElement } from '../../../packages/editor/src/utils/dom'
9+
import Boot from '../../../packages/editor/src/Boot'
810

911
function customCreateEditor(config: Partial<ICreateEditorOption> = {}) {
1012
const editorContainer = document.createElement('div')
@@ -29,14 +31,30 @@ function customCreateToolbar(config: Partial<ICreateToolbarOption> = {}) {
2931
// create toolbar
3032
const toolbar = createToolbar({
3133
editor,
32-
selector: toolbarContainer,
34+
selector: toolbarContainer as DOMElement,
3335
...config,
3436
})
3537

3638
return toolbar
3739
}
3840

3941
describe('create editor and toolbar', () => {
42+
test('create editor selector undefind', () => {
43+
const editor = customCreateEditor()
44+
expect(() => {
45+
createToolbar({
46+
editor,
47+
selector: undefined as any,
48+
})
49+
}).toThrow(`Cannot find 'selector' when create toolbar`)
50+
})
51+
52+
test('test new Boot and registerModule', () => {
53+
expect(() => {
54+
new Boot()
55+
}).toThrow('不能例化\nCan not construct a instance')
56+
})
57+
4058
test('create editor with default mode', () => {
4159
const editor = customCreateEditor()
4260

0 commit comments

Comments
 (0)