Skip to content

Commit

Permalink
Updated tests in WTA.
Browse files Browse the repository at this point in the history
  • Loading branch information
niegowski committed Jul 6, 2023
1 parent 1b6f192 commit e613d39
Showing 1 changed file with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ describe( 'WidgetTypeAround', () => {
expect( modelSelection.getAttribute( TYPE_AROUND_SELECTION_ATTRIBUTE ) ).to.be.undefined;
} );

it( 'should split ancestors to find a place that allows a widget', () => {
it( 'should split ancestors to find a place that allows a widget (no content after widget)', () => {
model.schema.register( 'allowP', {
inheritAllFrom: '$block'
} );
Expand Down Expand Up @@ -1083,7 +1083,41 @@ describe( 'WidgetTypeAround', () => {
'<allowP>' +
'<disallowP><blockWidget></blockWidget></disallowP>' +
'<paragraph>[]</paragraph>' +
'<disallowP></disallowP>' +
'</allowP>'
);
} );

it( 'should split ancestors to find a place that allows a widget (with content after widget)', () => {
model.schema.register( 'allowP', {
inheritAllFrom: '$block'
} );
model.schema.register( 'disallowP', {
inheritAllFrom: '$block',
allowIn: [ 'allowP' ]
} );
model.schema.extend( 'blockWidget', {
allowIn: [ 'allowP', 'disallowP' ]
} );
model.schema.extend( 'paragraph', {
allowIn: [ 'allowP' ]
} );

editor.conversion.for( 'downcast' ).elementToElement( { model: 'allowP', view: 'allowP' } );
editor.conversion.for( 'downcast' ).elementToElement( { model: 'disallowP', view: 'disallowP' } );

setModelData( model,
'<allowP>' +
'<disallowP>[<blockWidget></blockWidget>]<blockWidget></blockWidget></disallowP>' +
'</allowP>'
);

fireEnter();

expect( getModelData( model ) ).to.equal(
'<allowP>' +
'<disallowP><blockWidget></blockWidget></disallowP>' +
'<paragraph>[]</paragraph>' +
'<disallowP><blockWidget></blockWidget></disallowP>' +
'</allowP>'
);
} );
Expand Down

0 comments on commit e613d39

Please sign in to comment.