Skip to content

Commit

Permalink
test(editor): add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cycleccc committed Aug 17, 2024
1 parent 7b5fec7 commit e37a391
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/editor/__tests__/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ICreateEditorOption> = {}) {
const editorContainer = document.createElement('div')
Expand All @@ -29,14 +31,30 @@ function customCreateToolbar(config: Partial<ICreateToolbarOption> = {}) {
// create toolbar
const toolbar = createToolbar({
editor,
selector: toolbarContainer,
selector: toolbarContainer as DOMElement,
...config,
})

return toolbar
}

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()

Expand Down

0 comments on commit e37a391

Please sign in to comment.