import { Keys } from '@ephox/agar'; import { describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyContentActions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; describe('browser.tinymce.core.keyboard.EnterKeyHrTest', () => { const hook = TinyHooks.bddSetupLight({ indent: false, base_url: '/project/tinymce/js/tinymce' }, [], true); it('Enter before HR in the beginning of content', () => { const editor = hook.editor(); editor.setContent('

a

'); TinySelections.setCursor(editor, [], 0); TinyContentActions.keystroke(editor, Keys.enter()); TinyAssertions.assertContent(editor, '

 


a

'); TinyAssertions.assertSelection(editor, [ 0 ], 0, [ 0 ], 0); }); it('Enter after HR in the beginning of content', () => { const editor = hook.editor(); editor.setContent('

a

'); TinySelections.setCursor(editor, [], 1); TinyContentActions.keystroke(editor, Keys.enter()); TinyAssertions.assertContent(editor, '

 

a

'); TinyAssertions.assertSelection(editor, [ 2, 0 ], 0, [ 2, 0 ], 0); }); it('Enter before HR in the middle of content', () => { const editor = hook.editor(); editor.setContent('

a


b

'); TinySelections.setCursor(editor, [], 1); TinyContentActions.keystroke(editor, Keys.enter()); TinyAssertions.assertContent(editor, '

a

 


b

'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('Enter after HR in the middle of content', () => { const editor = hook.editor(); editor.setContent('

a


b

'); TinySelections.setCursor(editor, [], 2); TinyContentActions.keystroke(editor, Keys.enter()); TinyAssertions.assertContent(editor, '

a


 

b

'); TinyAssertions.assertSelection(editor, [ 3, 0 ], 0, [ 3, 0 ], 0); }); it('Enter before HR in the end of content', () => { const editor = hook.editor(); editor.setContent('

a


'); TinySelections.setCursor(editor, [], 1); TinyContentActions.keystroke(editor, Keys.enter()); TinyAssertions.assertContent(editor, '

a

 


'); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); }); it('Enter after HR in the end of content', () => { const editor = hook.editor(); editor.setContent('

a


'); TinySelections.setCursor(editor, [], 2); TinyContentActions.keystroke(editor, Keys.enter()); TinyAssertions.assertContent(editor, '

a


 

'); TinyAssertions.assertSelection(editor, [ 2 ], 0, [ 2 ], 0); }); });