import { Keys } from '@ephox/agar'; import { beforeEach, context, 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.TableNavigationTest', () => { const hook = TinyHooks.bddSetupLight({ indent: false, base_url: '/project/tinymce/js/tinymce' }, []); beforeEach(() => { hook.editor().focus(); }); context('Up navigation', () => { it('Arrow up on first position in table cell', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0, 0, 0, 0 ], 0); TinyContentActions.keystroke(editor, Keys.up()); TinyAssertions.assertSelection(editor, [ 0 ], 0, [ 0 ], 0); TinyAssertions.assertContent(editor, '

 

ab
'); }); it('Arrow up on first position in table cell to caption', () => { const editor = hook.editor(); editor.setContent('
a
b
'); TinySelections.setCursor(editor, [ 0, 1, 0, 0, 0 ], 0); TinyContentActions.keystroke(editor, Keys.up()); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 0, 0 ], 0); TinyAssertions.assertContent(editor, '
a
b
'); }); it('Arrow up on second position in first table cell', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0, 0, 0, 0 ], 1); TinyContentActions.keystroke(editor, Keys.up()); TinyAssertions.assertSelection(editor, [ 0 ], 0, [ 0 ], 0); TinyAssertions.assertContent(editor, '

 

ab
'); }); it('Arrow up on first position in first table cell on the second row', () => { const editor = hook.editor(); editor.setContent('
ab
cd
'); TinySelections.setCursor(editor, [ 0, 0, 1, 0, 0 ], 0); TinyContentActions.keystroke(editor, Keys.up()); TinyAssertions.assertSelection(editor, [ 0, 0, 0, 0, 0 ], 0, [ 0, 0, 0, 0, 0 ], 0); TinyAssertions.assertContent(editor, '
ab
cd
'); }); }); context('Down navigation', () => { it('Arrow down on last position in last table cell', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0, 0, 1, 0 ], 1); TinyContentActions.keystroke(editor, Keys.down()); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); TinyAssertions.assertContent(editor, '
ab

 

'); }); it('Arrow down on last position in last table cell with br', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0, 0, 1, 0 ], 1); TinyContentActions.keystroke(editor, Keys.down()); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); TinyAssertions.assertContent(editor, '
ab

 

'); }); it('Arrow down on second last position in last table cell', () => { const editor = hook.editor(); editor.setContent('
ab
'); TinySelections.setCursor(editor, [ 0, 0, 0, 1, 0 ], 0); TinyContentActions.keystroke(editor, Keys.down()); TinyAssertions.assertSelection(editor, [ 1 ], 0, [ 1 ], 0); TinyAssertions.assertContent(editor, '
ab

 

'); }); it('Arrow down on last position in last table cell on the first row', () => { const editor = hook.editor(); editor.setContent('
ab
cd
'); TinySelections.setCursor(editor, [ 0, 0, 0, 1, 0 ], 1); TinyContentActions.keystroke(editor, Keys.down()); TinyAssertions.assertSelection(editor, [ 0, 0, 1, 1, 0 ], 1, [ 0, 0, 1, 1, 0 ], 1); TinyAssertions.assertContent(editor, '
ab
cd
'); }); }); });