From e37a39194f6bf1e81d4b7345ef73fde23c2d739b Mon Sep 17 00:00:00 2001 From: cycleccc <2991205548@qq.com> Date: Sat, 17 Aug 2024 17:21:20 +0800 Subject: [PATCH] test(editor): add more tests --- packages/editor/__tests__/create.test.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/editor/__tests__/create.test.ts b/packages/editor/__tests__/create.test.ts index 8f6240ea9..411bf2335 100644 --- a/packages/editor/__tests__/create.test.ts +++ b/packages/editor/__tests__/create.test.ts @@ -5,6 +5,8 @@ import { createEditor, createToolbar } from '../../../packages/editor/src/index' import { ICreateEditorOption, ICreateToolbarOption } from '../../../packages/editor/src/create' +import { DOMElement } from '../../../packages/editor/src/utils/dom' +import Boot from '../../../packages/editor/src/Boot' function customCreateEditor(config: Partial = {}) { const editorContainer = document.createElement('div') @@ -29,7 +31,7 @@ function customCreateToolbar(config: Partial = {}) { // create toolbar const toolbar = createToolbar({ editor, - selector: toolbarContainer, + selector: toolbarContainer as DOMElement, ...config, }) @@ -37,6 +39,22 @@ function customCreateToolbar(config: Partial = {}) { } describe('create editor and toolbar', () => { + test('create editor selector undefind', () => { + const editor = customCreateEditor() + expect(() => { + createToolbar({ + editor, + selector: undefined as any, + }) + }).toThrow(`Cannot find 'selector' when create toolbar`) + }) + + test('test new Boot and registerModule', () => { + expect(() => { + new Boot() + }).toThrow('不能实例化\nCan not construct a instance') + }) + test('create editor with default mode', () => { const editor = customCreateEditor()