-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 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' }, | ||
]) | ||
}) | ||
}) |