-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cycleccc:master' into master
- Loading branch information
Showing
9 changed files
with
136 additions
and
43 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/basic-modules/__tests__/common/enter-menu.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @description enter menu test | ||
* @author cycleccc | ||
*/ | ||
|
||
import { Editor, Transforms } from 'slate' | ||
import createEditor from '../../../../tests/utils/create-editor' | ||
import EnterMenu from '../../src/modules/common/menu/EnterMenu' | ||
|
||
describe('enter menu', () => { | ||
const menu = new EnterMenu() | ||
let editor: any | ||
let startLocation: any | ||
|
||
beforeEach(() => { | ||
editor = createEditor() | ||
startLocation = Editor.start(editor, []) | ||
}) | ||
|
||
afterEach(() => { | ||
editor = null | ||
startLocation = null | ||
}) | ||
|
||
it('get value', () => { | ||
expect(menu.getValue(editor)).toBe('') | ||
}) | ||
|
||
it('is active', () => { | ||
expect(menu.isActive(editor)).toBeFalsy() | ||
}) | ||
|
||
it('is disabled', () => { | ||
editor.deselect() | ||
expect(menu.isDisabled(editor)).toBeTruthy() | ||
editor.select(startLocation) | ||
expect(menu.isDisabled(editor)).toBeFalsy() | ||
editor.insertText('hello') | ||
editor.select([]) | ||
expect(menu.isDisabled(editor)).toBeTruthy() | ||
}) | ||
|
||
it('exec', () => { | ||
editor.deselect() | ||
expect(menu.exec(editor, '')).toBeUndefined() | ||
editor.select(startLocation) | ||
menu.exec(editor, '') | ||
expect(editor.children).toStrictEqual([ | ||
{ children: [{ text: '' }], type: 'paragraph' }, | ||
{ children: [{ text: '' }], type: 'paragraph' }, | ||
]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @description utils dom | ||
* @author cycleccc | ||
*/ | ||
|
||
import { getTagName } from '../../src/utils/dom' | ||
import { Dom7Array } from 'dom7' | ||
|
||
describe('redo menu', () => { | ||
it('get tag name', () => { | ||
// 模拟一个空的 Dom7Array 对象 | ||
const emptyElem: Dom7Array = [] as unknown as Dom7Array | ||
|
||
const result = getTagName(emptyElem) | ||
expect(result).toBe('') // 验证返回的是空字符串 | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters