From a0d81ef3404f57c02d1c13801ba000899195e4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Sun, 26 Feb 2017 18:16:36 +0100 Subject: [PATCH] Improved the tests a bit. --- tests/entercommand.js | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/tests/entercommand.js b/tests/entercommand.js index 3edd0bb..7484b03 100644 --- a/tests/entercommand.js +++ b/tests/entercommand.js @@ -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' ); } ); } ); @@ -112,27 +118,27 @@ describe( 'EnterCommand', () => { ); test( - 'should not break limit elements - collapsed', - 'foo[]bar', - 'foo[]bar' + 'should not break inline limit elements - collapsed', + '

foo[]bar

', + '

foo[]bar

' ); test( - 'should not break limit elements', - 'foo[bar]baz', - 'foo[bar]baz' + 'should not break inline limit elements', + '

foo[bar]baz

', + '

foo[bar]baz

' ); test( - 'should not break limit elements - selection partially inside', - '

fo[o

ba]r', - '

fo[o

ba]r' + 'should not break inline limit elements - selection partially inside', + '

ba[r

f]oo

', + '

ba[r

f]oo

' ); test( - 'should delete limit element when fully contained inside selection', - '

fo[o

bar

ba]z

', - '

fo

[]z

' + 'should break paragraph in blockLimit', + '

foo[]bar

', + '

foo

[]bar

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