Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Internal: Align code to the API changes (selection post-fixer).
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Jun 27, 2018
1 parent f3b7d0b commit 1936e25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions tests/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ describe( 'TableEditing', () => {
} );

describe( 'on table widget selected', () => {
beforeEach( () => {
editor.model.schema.register( 'block', {
allowWhere: '$block',
allowContentOf: '$block',
isObject: true
} );

editor.conversion.elementToElement( { model: 'block', view: 'block' } );
} );

it( 'should move caret to the first table cell on TAB', () => {
const spy = sinon.spy();

Expand All @@ -265,19 +275,19 @@ describe( 'TableEditing', () => {
sinon.assert.notCalled( spy );
} );

it( 'shouldn\' do anything on other blocks', () => {
it( 'shouldn\'t do anything on other blocks', () => {
const spy = sinon.spy();

editor.editing.view.document.on( 'keydown', spy );

setModelData( model, '[<paragraph>foo</paragraph>]' );
setModelData( model, '[<block>foo</block>]' );

editor.editing.view.document.fire( 'keydown', domEvtDataStub );

sinon.assert.notCalled( domEvtDataStub.preventDefault );
sinon.assert.notCalled( domEvtDataStub.stopPropagation );

expect( formatTable( getModelData( model ) ) ).to.equal( '[<paragraph>foo</paragraph>]' );
expect( formatTable( getModelData( model ) ) ).to.equal( '[<block>foo</block>]' );

// Should not cancel event.
sinon.assert.calledOnce( spy );
Expand Down
6 changes: 3 additions & 3 deletions tests/tabletoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@ describe( 'TableToolbar', () => {
} );

it( 'should show the toolbar on render when the table content is selected', () => {
setData( model, '<paragraph>[foo]</paragraph><table><tableRow><tableCell></tableCell></tableRow></table>' );
setData( model, '<paragraph>[foo]</paragraph><table><tableRow><tableCell>bar</tableCell></tableRow></table>' );

expect( balloon.visibleView ).to.be.null;

editingView.change( () => {} );
expect( balloon.visibleView ).to.be.null;

model.change( writer => {
// Select the [<tableCell></tableCell>]
// Select the <tableCell>[foo]</tableCell>
writer.setSelection(
Range.createOn( doc.getRoot().getChild( 1 ).getChild( 0 ).getChild( 0 ) )
Range.createOn( doc.getRoot().getChild( 1 ).getChild( 0 ).getChild( 0 ).getChild( 0 ) )
);
} );

Expand Down

0 comments on commit 1936e25

Please sign in to comment.