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

Commit

Permalink
Improved the tests a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Feb 26, 2017
1 parent 535f309 commit a0d81ef
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions tests/entercommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ describe( 'EnterCommand', () => {
schema.registerItem( 'img', '$inline' );
schema.registerItem( 'p', '$block' );
schema.registerItem( 'h', '$block' );
schema.registerItem( 'w' );
schema.allow( { name: 'w', inside: '$root' } );
schema.allow( { name: '$text', inside: 'w' } );
schema.limits.add( 'w' );
schema.registerItem( 'inlineLimit' );
schema.registerItem( 'blockLimit' );

schema.allow( { name: 'inlineLimit', inside: 'p' } );
schema.allow( { name: '$text', inside: 'inlineLimit' } );
schema.allow( { name: '$text', inside: '$root' } );
schema.allow( { name: 'blockLimit', inside: '$root' } );
schema.allow( { name: 'p', inside: 'blockLimit' } );

schema.limits.add( 'inlineLimit' );
schema.limits.add( 'blockLimit' );
} );
} );

Expand Down Expand Up @@ -112,27 +118,27 @@ describe( 'EnterCommand', () => {
);

test(
'should not break limit elements - collapsed',
'<w>foo[]bar</w>',
'<w>foo[]bar</w>'
'should not break inline limit elements - collapsed',
'<p><inlineLimit>foo[]bar</inlineLimit></p>',
'<p><inlineLimit>foo[]bar</inlineLimit></p>'
);

test(
'should not break limit elements',
'<w>foo[bar]baz</w>',
'<w>foo[bar]baz</w>'
'should not break inline limit elements',
'<p><inlineLimit>foo[bar]baz</inlineLimit></p>',
'<p><inlineLimit>foo[bar]baz</inlineLimit></p>'
);

test(
'should not break limit elements - selection partially inside',
'<p>fo[o</p><w>ba]r</w>',
'<p>fo[o</p><w>ba]r</w>'
'should not break inline limit elements - selection partially inside',
'<p><inlineLimit>ba[r</inlineLimit></p><p>f]oo</p>',
'<p><inlineLimit>ba[r</inlineLimit></p><p>f]oo</p>'
);

test(
'should delete limit element when fully contained inside selection',
'<p>fo[o</p><w>bar</w><p>ba]z</p>',
'<p>fo</p><p>[]z</p>'
'should break paragraph in blockLimit',
'<blockLimit><p>foo[]bar</p></blockLimit>',
'<blockLimit><p>foo</p><p>[]bar</p></blockLimit>'
);

it( 'leaves one empty element after two were fully selected (backward)', () => {
Expand Down

0 comments on commit a0d81ef

Please sign in to comment.