From ae2c6cfbac555a69a958ec8005bf2d2e8d5e9d8b Mon Sep 17 00:00:00 2001 From: Mgsy Date: Mon, 6 Aug 2018 16:33:10 +0200 Subject: [PATCH 1/5] Added: Test cases with a range inside a block. --- tests/model/operation/transform/attribute.js | 56 ++++++++++++ tests/model/operation/transform/marker.js | 90 ++++++++++++++++++++ tests/model/operation/transform/move.js | 71 +++++++++++++++ tests/model/operation/transform/remove.js | 86 ++++++++++++++++++- tests/model/operation/transform/rename.js | 64 ++++++++++++-- 5 files changed, 360 insertions(+), 7 deletions(-) diff --git a/tests/model/operation/transform/attribute.js b/tests/model/operation/transform/attribute.js index 6a5d0f775..874d33b1f 100644 --- a/tests/model/operation/transform/attribute.js +++ b/tests/model/operation/transform/attribute.js @@ -376,6 +376,21 @@ describe( 'transform', () => { ); } ); + it( 'text into div in different path', () => { + john.setData( '[Foo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.setAttribute( 'bold', true ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( + '<$text bold="true">Foo' + + '
Bar
' + ); + } ); + it( 'element into blockQuote in same path #1', () => { john.setData( '[Foo]' ); kate.setData( '[Foo]' ); @@ -407,6 +422,18 @@ describe( 'transform', () => { '' ); } ); + + it( 'text into div in same path', () => { + john.setData( '[Foo]' ); + kate.setData( '[Foo]' ); + + john.setAttribute( 'bold', true ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( '
<$text bold="true">Foo
' ); + } ); } ); describe( 'by unwrap', () => { @@ -440,6 +467,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( '[Foo]
Bar
' ); + kate.setData( 'Foo
[Bar]
' ); + + john.setAttribute( 'bold', true ); + kate.unwrap(); + + syncClients(); + + expectClients( + '<$text bold="true">Foo' + + '
Bar
' + ); + } ); + it( 'element in same path #1', () => { john.setData( '
[Foo]
' ); kate.setData( '
[Foo]
' ); @@ -465,6 +507,20 @@ describe( 'transform', () => { expectClients( 'Foo' ); } ); + + it( 'text in same path', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.setAttribute( 'bold', true ); + kate.unwrap(); + + syncClients(); + + expectClients( + '
<$text bold="true">Foo
' + ); + } ); } ); describe( 'by split', () => { diff --git a/tests/model/operation/transform/marker.js b/tests/model/operation/transform/marker.js index 07b4a2f2b..5fb5565d4 100644 --- a/tests/model/operation/transform/marker.js +++ b/tests/model/operation/transform/marker.js @@ -488,6 +488,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( '[Foo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.setMarker( 'm1' ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( + 'Foo' + + '
Bar
' + ); + } ); + it( 'element in same path', () => { john.setData( '[Foo]' ); kate.setData( '[Foo]' ); @@ -504,6 +519,18 @@ describe( 'transform', () => { ); } ); + it( 'text in same path', () => { + john.setData( '[Foo]' ); + kate.setData( '[Foo]' ); + + john.setMarker( 'm1' ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( '
Foo
' ); + } ); + it( 'element in same path, then undo', () => { john.setData( '[Foo]' ); kate.setData( '[Foo]' ); @@ -523,6 +550,22 @@ describe( 'transform', () => { '' ); } ); + + it( 'text in same path, then undo', () => { + john.setData( '[Foo]' ); + kate.setData( '[Foo]' ); + + john.setMarker( 'm1' ); + kate.wrap( 'div' ); + + syncClients(); + + john.undo(); + + syncClients(); + + expectClients( '
Foo
' ); + } ); } ); describe( 'by unwrap', () => { @@ -541,6 +584,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( '[Foo]
Bar
' ); + kate.setData( 'Foo
[Bar]
' ); + + john.setMarker( 'm1' ); + kate.unwrap(); + + syncClients(); + + expectClients( + 'Foo' + + '
Bar
' + ); + } ); + it( 'element in same path', () => { john.setData( '
[Foo]
' ); kate.setData( '
[Foo]
' ); @@ -555,6 +613,20 @@ describe( 'transform', () => { ); } ); + it( 'text in same path', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.setMarker( 'm1' ); + kate.unwrap(); + + syncClients(); + + expectClients( + '
Foo
' + ); + } ); + it( 'element in same path, then undo', () => { john.setData( '
[Foo]
' ); kate.setData( '
[Foo]
' ); @@ -572,6 +644,24 @@ describe( 'transform', () => { 'Foo' ); } ); + + it( 'text in same path, then undo', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.setMarker( 'm1' ); + kate.unwrap(); + + syncClients(); + + john.undo(); + + syncClients(); + + expectClients( + '
Foo
' + ); + } ); } ); describe( 'by split', () => { diff --git a/tests/model/operation/transform/move.js b/tests/model/operation/transform/move.js index f54108ef8..700ab6074 100644 --- a/tests/model/operation/transform/move.js +++ b/tests/model/operation/transform/move.js @@ -192,6 +192,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( 'F[oo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.move( [ 0, 0 ] ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( + 'ooF' + + '
Bar
' + ); + } ); + it( 'element in same path', () => { john.setData( 'F[oo]' ); kate.setData( '[Foo]' ); @@ -208,6 +223,18 @@ describe( 'transform', () => { ); } ); + it( 'text in same path', () => { + john.setData( 'F[oo]' ); + kate.setData( '[Foo]' ); + + john.move( [ 0, 0 ] ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( 'oo
F
' ); + } ); + it( 'element while moving', () => { john.setData( '[Foo]Bar' ); kate.setData( '[Foo]Bar' ); @@ -225,6 +252,21 @@ describe( 'transform', () => { ); } ); + it( 'element while moving', () => { + john.setData( '[Foo]Bar' ); + kate.setData( '[Foo]Bar' ); + + john.move( [ 1, 0 ] ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( + '
' + + 'FooBar' + ); + } ); + it( 'intersecting wrap', () => { john.setData( 'F[oo]Bar' ); kate.setData( '[Foo]Bar' ); @@ -272,6 +314,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( 'F[oo]
Bar
' ); + kate.setData( 'Foo
[Bar]
' ); + + john.move( [ 0, 0 ] ); + kate.unwrap(); + + syncClients(); + + expectClients( + 'ooF' + + '
Bar
' + ); + } ); + it( 'element in same path', () => { john.setData( '
F[oo]
' ); kate.setData( '
[Foo]
' ); @@ -285,6 +342,20 @@ describe( 'transform', () => { 'ooF' ); } ); + + it( 'text in same path', () => { + john.setData( '
F[oo]
' ); + kate.setData( '
[Foo]
' ); + + john.move( [ 0, 0, 0 ] ); + kate.unwrap(); + + syncClients(); + + expectClients( + '
ooF
' + ); + } ); } ); describe( 'by split', () => { diff --git a/tests/model/operation/transform/remove.js b/tests/model/operation/transform/remove.js index 92cbc090b..7cc269e6e 100644 --- a/tests/model/operation/transform/remove.js +++ b/tests/model/operation/transform/remove.js @@ -124,6 +124,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( '[Foo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.remove(); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( + '' + + '
Bar
' + ); + } ); + it( 'element in same path', () => { john.setData( '[Foo]' ); kate.setData( '[Foo]' ); @@ -138,6 +153,18 @@ describe( 'transform', () => { ); } ); + it( 'text in same path', () => { + john.setData( '[Foo] Bar' ); + kate.setData( '[Foo Bar]' ); + + john.remove(); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( '
Bar
' ); + } ); + it( 'element while removing', () => { john.setData( 'Foo[Bar]' ); kate.setData( 'Foo[Bar]' ); @@ -163,8 +190,6 @@ describe( 'transform', () => { syncClients(); - // Actual content: - // FooBar
expectClients( 'Foo' + '
' + @@ -172,6 +197,34 @@ describe( 'transform', () => { '
' ); } ); + + it( 'text while removing', () => { + john.setData( '[Foo]' ); + kate.setData( '[Foo]' ); + + john.remove(); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( '' ); + } ); + + it( 'text while removing, then undo', () => { + john.setData( '[Foo]' ); + kate.setData( '[Foo]' ); + + john.remove(); + kate.wrap( 'div' ); + + syncClients(); + + john.undo(); + + syncClients(); + + expectClients( '
Foo
' ); + } ); } ); describe( 'by unwrap', () => { @@ -190,6 +243,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( '[Foo]
Bar
' ); + kate.setData( 'Foo
[Bar]
' ); + + john.remove(); + kate.unwrap(); + + syncClients(); + + expectClients( + '' + + '
Bar
' + ); + } ); + it( 'element in same path', () => { john.setData( '
[Foo]
' ); kate.setData( '
[Foo]
' ); @@ -204,6 +272,20 @@ describe( 'transform', () => { ); } ); + it( 'text in same path', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.remove(); + kate.unwrap(); + + syncClients(); + + expectClients( + '
' + ); + } ); + it( 'element while removing', () => { john.setData( 'Foo
[Bar]
' ); kate.setData( 'Foo
[Bar]
' ); diff --git a/tests/model/operation/transform/rename.js b/tests/model/operation/transform/rename.js index 0b424ad3f..f2aaa92d5 100644 --- a/tests/model/operation/transform/rename.js +++ b/tests/model/operation/transform/rename.js @@ -129,15 +129,15 @@ describe( 'transform', () => { } ); it( 'the same element', () => { - john.setData( '
[]Foo Bar
' ); - kate.setData( '
[]Foo Bar
' ); + john.setData( '
[]Foo Bar
' ); + kate.setData( '
[]Foo Bar
' ); - john.rename( 'blockQuote2' ); - kate.rename( 'blockQuote3' ); + john.rename( 'heading1' ); + kate.rename( 'heading2' ); syncClients(); - expectClients( 'Foo Bar' ); + expectClients( '
Foo Bar
' ); } ); } ); @@ -218,6 +218,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( '[]FooBar' ); + kate.setData( 'Foo[Bar]' ); + + john.rename( 'heading1' ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( + 'Foo' + + '
Bar
' + ); + } ); + it( 'element in same path', () => { john.setData( '[]Foo' ); kate.setData( '[Foo]' ); @@ -229,6 +244,18 @@ describe( 'transform', () => { expectClients( '
Foo
' ); } ); + + it( 'text in same path', () => { + john.setData( '[]Foo' ); + kate.setData( '[Foo]' ); + + john.rename( 'heading1' ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( '
Foo
' ); + } ); } ); describe( 'by unwrap', () => { @@ -247,6 +274,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( 'F[]oo
Bar
' ); + kate.setData( 'Foo
[Bar]
' ); + + john.rename( 'heading1' ); + kate.unwrap(); + + syncClients(); + + expectClients( + 'Foo' + + '
Bar
' + ); + } ); + it( 'element in same path', () => { john.setData( '
F[]oo
' ); kate.setData( '
[Foo]
' ); @@ -260,6 +302,18 @@ describe( 'transform', () => { 'Foo' ); } ); + + it( 'text in same path', () => { + john.setData( '
F[]oo
' ); + kate.setData( '
[Foo]
' ); + + john.rename( 'heading1' ); + kate.unwrap(); + + syncClients(); + + expectClients( '
Foo
' ); + } ); } ); describe( 'by merge', () => { From 89a5546658b81e42e4daf0c38ab69048e0b3179f Mon Sep 17 00:00:00 2001 From: Mgsy Date: Tue, 7 Aug 2018 11:38:43 +0200 Subject: [PATCH 2/5] Added: Test cases with a range inside a block. --- tests/model/operation/transform/split.js | 67 +++++++++++++++++++++++ tests/model/operation/transform/unwrap.js | 52 +++++++++++++++++- tests/model/operation/transform/wrap.js | 42 ++++++++++++++ 3 files changed, 160 insertions(+), 1 deletion(-) diff --git a/tests/model/operation/transform/split.js b/tests/model/operation/transform/split.js index 7f02b915c..9aa47c19e 100644 --- a/tests/model/operation/transform/split.js +++ b/tests/model/operation/transform/split.js @@ -52,6 +52,40 @@ describe( 'transform', () => { ); } ); + it( 'text in same path', () => { + john.setData( 'F[]oo' ); + kate.setData( '[Foo]' ); + + john.split(); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( + '
F
' + + '
oo
' + ); + } ); + + it( 'text in same path, then undo', () => { + john.setData( 'F[]oo' ); + kate.setData( '[Foo]' ); + + john.split(); + kate.wrap( 'div' ); + + syncClients(); + + kate.undo(); + + syncClients(); + + expectClients( + 'F' + + 'oo' + ); + } ); + it( 'multiple elements', () => { john.setData( 'F[]ooBar' ); kate.setData( '[FooBar]' ); @@ -122,6 +156,21 @@ describe( 'transform', () => { ); } ); + it( 'text in same path', () => { + john.setData( '
F[]oo
' ); + kate.setData( '
[Foo]
' ); + + john.split(); + kate.unwrap(); + + syncClients(); + + expectClients( + '
F
' + + '
oo
' + ); + } ); + it.skip( 'element in same position', () => { john.setData( '
[]Foo
' ); kate.setData( '
[]Foo
' ); @@ -152,6 +201,24 @@ describe( 'transform', () => { ); } ); + it( 'text in same path, then undo', () => { + john.setData( '
F[]oo
' ); + kate.setData( '
[Foo]
' ); + + john.split(); + kate.unwrap(); + + syncClients(); + + john.undo(); + + syncClients(); + + expectClients( + '
Foo
' + ); + } ); + it( 'multiple elements', () => { john.setData( '
F[]ooBar
' ); kate.setData( '
[FooBar]
' ); diff --git a/tests/model/operation/transform/unwrap.js b/tests/model/operation/transform/unwrap.js index 0b14ddd1b..dbb1bc245 100644 --- a/tests/model/operation/transform/unwrap.js +++ b/tests/model/operation/transform/unwrap.js @@ -38,6 +38,28 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( + '
[Foo]
' + + '
Bar
' + ); + + kate.setData( + '
Foo
' + + '
[Bar]
' + ); + + john.unwrap(); + kate.unwrap(); + + syncClients(); + + expectClients( + '
Foo
' + + '
Bar
' + ); + } ); + it( 'the same element', () => { john.setData( '
[Foo]
' ); kate.setData( '
[Foo]
' ); @@ -68,10 +90,38 @@ describe( 'transform', () => { // Kate has a different order of nodes in graveyard after syncing. expectClients( '
Foo
' ); } ); + + it( 'the same text', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.unwrap(); + kate.unwrap(); + + syncClients(); + + expectClients( '
Foo
' ); + } ); + + it( 'the same text, then undo', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.unwrap(); + kate.unwrap(); + + syncClients(); + + john.undo(); + + syncClients(); + + expectClients( '
Foo
' ); + } ); } ); describe( 'by delete', () => { - it( 'text from two elements', () => { + it( 'text from two elements #1', () => { john.setData( '
[Foo]
Bar' ); kate.setData( '
Fo[o
Ba]r' ); diff --git a/tests/model/operation/transform/wrap.js b/tests/model/operation/transform/wrap.js index f7e125980..ef6ec22cc 100644 --- a/tests/model/operation/transform/wrap.js +++ b/tests/model/operation/transform/wrap.js @@ -31,6 +31,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( '[Foo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.wrap( 'div' ); + kate.wrap( 'div2' ); + + syncClients(); + + expectClients( + '
Foo
' + + 'Bar' + ); + } ); + it( 'the same element', () => { john.setData( '[Foo]' ); kate.setData( '[Foo]' ); @@ -142,6 +157,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( '[Foo]
Bar
' ); + kate.setData( 'Foo
[Bar]
' ); + + john.wrap( 'div' ); + kate.unwrap(); + + syncClients(); + + expectClients( + '
Foo
' + + '
Bar
' + ); + } ); + it( 'the same element', () => { john.setData( '
[Foo]
' ); kate.setData( '
[Foo]
' ); @@ -169,6 +199,18 @@ describe( 'transform', () => { expectClients( '
Foo
' ); } ); + + it( 'the same text', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.wrap( 'div' ); + kate.unwrap(); + + syncClients(); + + expectClients( '
Foo
' ); + } ); } ); describe( 'by delete', () => { From 2fa6fd09f4107d4c5cf48cdb19f9aa668454a41e Mon Sep 17 00:00:00 2001 From: Mgsy Date: Tue, 7 Aug 2018 12:43:04 +0200 Subject: [PATCH 3/5] Added: New scenarios and cleanup. --- tests/model/operation/transform/attribute.js | 426 +++++++++++++++++++ tests/model/operation/transform/insert.js | 143 ++++--- tests/model/operation/transform/marker.js | 93 ---- tests/model/operation/transform/move.js | 89 ---- tests/model/operation/transform/remove.js | 88 ---- tests/model/operation/transform/rename.js | 88 ---- 6 files changed, 500 insertions(+), 427 deletions(-) diff --git a/tests/model/operation/transform/attribute.js b/tests/model/operation/transform/attribute.js index 874d33b1f..fede8c4d6 100644 --- a/tests/model/operation/transform/attribute.js +++ b/tests/model/operation/transform/attribute.js @@ -232,6 +232,21 @@ describe( 'transform', () => { ); } ); + it( 'text between changed nodes', () => { + john.setData( '[FooBar]' ); + kate.setData( 'FooB[]ar' ); + + john.setAttribute( 'bold', true ); + kate.type( 'Abc' ); + + syncClients(); + + expectClients( + '<$text bold="true">Foo' + + '<$text bold="true">BAbcar' + ); + } ); + it( 'element in different path', () => { john.setData( '[Foo]Bar' ); kate.setData( 'FooBar[]' ); @@ -263,6 +278,68 @@ describe( 'transform', () => { 'Abc' ); } ); + + it( 'remove attribute from element in different path', () => { + john.setData( '[]FooBar' ); + kate.setData( 'Foo[Bar]' ); + + john.type( 'Abc' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( 'AbcFooBar' ); + } ); + + it( 'remove attribute from text in different path', () => { + john.setData( '[]Foo<$text bold="true">Bar' ); + kate.setData( 'Foo<$text bold="true">[Bar]' ); + + john.type( 'Abc' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( 'AbcFooBar' ); + } ); + + it( 'remove attribute from text in same path', () => { + john.setData( '[]Fo<$text bold="true">o' ); + kate.setData( 'Fo<$text bold="true">[o]' ); + + john.type( 'Bar' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( 'BarFoo' ); + } ); + + it( 'remove attribute from element in same path', () => { + john.setData( '[]Foo' ); + kate.setData( '[Foo]' ); + + john.type( 'Bar' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( 'BarFoo' ); + } ); + + it( 'remove attribute from text with 2 attributes in same path', () => { + john.setData( '[]Fo<$text bold="true" italic="true">o' ); + kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); + + john.type( 'Bar' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'BarFo<$text italic="true">o' + ); + } ); } ); describe( 'by move', () => { @@ -343,6 +420,93 @@ describe( 'transform', () => { expectClients( 'F Baroo' ); } ); + + it( 'remove attribute from element in different path', () => { + john.setData( 'F[oo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.move( [ 1, 0 ] ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'F' + + 'ooBar' + ); + } ); + + it( 'remove attribute from text in different path', () => { + john.setData( 'F[oo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.move( [ 1, 0 ] ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'F' + + 'ooBar' + ); + } ); + + it( 'remove attribute from text in same path', () => { + john.setData( '[Fo]<$text bold="true">o' ); + kate.setData( 'Fo<$text bold="true">[o]' ); + + john.move( [ 0, 3 ] ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'oFo' + ); + } ); + + it( 'remove attribute from element in same path', () => { + john.setData( '[Fo]o' ); + kate.setData( '[Foo]' ); + + john.move( [ 0, 3 ] ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'oFo' + ); + } ); + + it( 'remove attribute from text with 2 attributes in same path', () => { + john.setData( '[Fo]<$text bold="true" italic="true">o' ); + kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); + + john.move( [ 0, 3 ] ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + '<$text italic="true">oFo' + ); + } ); + + it( 'remove attribute from text in other user\'s selection', () => { + john.setData( '<$text bold="true">[Foo]' ); + kate.setData( '<$text bold="true">[Foo]' ); + + john.move( [ 1, 0 ] ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + '' + + 'Foo' + ); + } ); } ); describe( 'by wrap', () => { @@ -660,6 +824,92 @@ describe( 'transform', () => { '<$text bold="true">F' ); } ); + + it( 'remove attribute from element in different path', () => { + john.setData( 'F[oo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.remove(); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'F' + + 'Bar' + ); + } ); + + it( 'remove attribute from text in different path', () => { + john.setData( 'F[oo]<$text bold="true">Bar' ); + kate.setData( 'Foo<$text bold="true">[Bar]' ); + + john.remove(); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'F' + + 'Bar' + ); + } ); + + it( 'remove attribute from text in same path', () => { + john.setData( '[Fo]<$text bold="true">o' ); + kate.setData( 'Fo<$text bold="true">[o]' ); + + john.remove(); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'o' + ); + } ); + + it( 'remove attribute from element in same path', () => { + john.setData( '[Fo]o' ); + kate.setData( '[Foo]' ); + + john.remove(); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'o' + ); + } ); + + it( 'remove attribute from text with 2 attributes in same path', () => { + john.setData( '[Fo]<$text bold="true" italic="true">o' ); + kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); + + john.remove(); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + '<$text italic="true">o' + ); + } ); + + it( 'remove attribute from text in other user\'s selection', () => { + john.setData( '<$text bold="true">[Foo]' ); + kate.setData( '<$text bold="true">[Foo]' ); + + john.remove(); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + '' + ); + } ); } ); describe( 'by remove attribute', () => { @@ -836,6 +1086,96 @@ describe( 'transform', () => { expectClients( '<$text bold="true">Foo Bar' ); } ); + + it( 'remove attribute from element in different path', () => { + john.setData( '[Foo]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.setMarker( 'm1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + + 'Bar' + ); + } ); + + it( 'remove attribute from text in different path', () => { + john.setData( '[Foo]<$text bold="true">Bar' ); + kate.setData( 'Foo<$text bold="true">[Bar]' ); + + john.setMarker( 'm1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + + 'Bar' + ); + } ); + + it( 'remove attribute from text in same path', () => { + john.setData( '[Fo]<$text bold="true">o' ); + kate.setData( 'Fo<$text bold="true">[o]' ); + + john.setMarker( 'm1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + ); + } ); + + it( 'remove attribute from text in same path, then undo', () => { + john.setData( '[Fo]<$text bold="true">o' ); + kate.setData( 'Fo<$text bold="true">[o]' ); + + john.setMarker( 'm1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + kate.undo(); + + syncClients(); + + expectClients( + 'Fo<$text bold="true">o' + ); + } ); + + it( 'remove attribute from text with 2 attributes in same path', () => { + john.setData( '[Fo]<$text bold="true" italic="true">o' ); + kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); + + john.setMarker( 'm1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Fo<$text italic="true">o' + ); + } ); + + it( 'remove attribute from text in other user\'s selection', () => { + john.setData( '<$text bold="true">[Foo]' ); + kate.setData( '<$text bold="true">[Foo]' ); + + john.setMarker( 'm1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + ); + } ); } ); describe( 'by merge', () => { @@ -931,5 +1271,91 @@ describe( 'transform', () => { 'Foo' ); } ); + + it( 'remove attribute from element in different path', () => { + john.setData( 'F[]ooBar' ); + kate.setData( 'Foo[Bar]' ); + + john.rename( 'heading1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + + 'Bar' + ); + } ); + + it( 'remove attribute from text in different path', () => { + john.setData( 'F[]ooBar' ); + kate.setData( 'Foo[Bar]' ); + + john.rename( 'heading1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + + 'Bar' + ); + } ); + + it( 'remove attribute from text in same path', () => { + john.setData( 'F[]o<$text bold="true">o' ); + kate.setData( 'Fo<$text bold="true">[o]' ); + + john.rename( 'heading1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + ); + } ); + + it( 'remove attribute from element in same path', () => { + john.setData( 'F[]oo' ); + kate.setData( '[Foo]' ); + + john.rename( 'heading1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + ); + } ); + + it( 'remove attribute from text with 2 attributes in same path', () => { + john.setData( 'F[o]<$text bold="true" italic="true">o' ); + kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); + + john.rename( 'heading1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Fo<$text italic="true">o' + ); + } ); + + it( 'remove attribute from text in other user\'s selection', () => { + john.setData( '<$text bold="true">[Foo]' ); + kate.setData( '<$text bold="true">[Foo]' ); + + john.rename( 'heading1' ); + kate.removeAttribute( 'bold' ); + + syncClients(); + + expectClients( + 'Foo' + ); + } ); } ); } ); diff --git a/tests/model/operation/transform/insert.js b/tests/model/operation/transform/insert.js index 635116e14..b3e1fb6e6 100644 --- a/tests/model/operation/transform/insert.js +++ b/tests/model/operation/transform/insert.js @@ -216,6 +216,21 @@ describe( 'transform', () => { ); } ); + it( 'text at different paths', () => { + john.setData( '[]FooBar' ); + kate.setData( 'FooB[ar]' ); + + john.type( 'Abc' ); + kate.move( [ 1, 0 ] ); + + syncClients(); + + expectClients( + 'AbcFoo' + + 'arB' + ); + } ); + it( 'text at same path', () => { john.setData( 'F[]oo Bar' ); kate.setData( 'Foo B[ar]' ); @@ -254,7 +269,7 @@ describe( 'transform', () => { } ); describe( 'by wrap', () => { - it( 'element in same path', () => { + it( 'element in same path #1', () => { john.setData( 'Foo Bar[]' ); kate.setData( '[Foo Bar]' ); @@ -271,7 +286,7 @@ describe( 'transform', () => { ); } ); - it( 'element in same path', () => { + it( 'element in same path #2', () => { john.setData( 'Foo[]' ); kate.setData( '[Foo]' ); @@ -287,7 +302,19 @@ describe( 'transform', () => { ); } ); - it( 'element in different paths', () => { + it( 'text in same path', () => { + john.setData( 'Foo[]' ); + kate.setData( '[Foo]' ); + + john.type( 'Bar' ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( '
Foo
Bar
' ); + } ); + + it( 'element in different paths #1', () => { john.setData( 'Foo[]Bar' ); kate.setData( 'Foo[Bar]' ); @@ -305,7 +332,7 @@ describe( 'transform', () => { ); } ); - it( 'element in different paths', () => { + it( 'element in different paths #2', () => { john.setData( 'FooBar[]' ); kate.setData( '[Foo]Bar' ); @@ -322,6 +349,21 @@ describe( 'transform', () => { ); } ); + it( 'text in different paths', () => { + john.setData( 'Foo[]Bar' ); + kate.setData( 'Foo[Bar]' ); + + john.type( 'Abc' ); + kate.wrap( 'div' ); + + syncClients(); + + expectClients( + 'FooAbc' + + '
Bar
' + ); + } ); + it( 'element, then unwrap and split', () => { john.setData( 'Foo[]' ); kate.setData( '[Foo]' ); @@ -449,6 +491,20 @@ describe( 'transform', () => { ); } ); + it( 'text in different path', () => { + john.setData( 'Foo[]
Bar
' ); + kate.setData( 'Foo
[Bar]
' ); + + john.type( 'Abc' ); + kate.unwrap(); + + syncClients(); + + expectClients( + 'FooAbc
Bar
' + ); + } ); + it( 'element in same path #1', () => { john.setData( '
Foo[]
' ); kate.setData( '
[Foo]
' ); @@ -478,6 +534,20 @@ describe( 'transform', () => { ); } ); + it( 'text in same path', () => { + john.setData( '
Foo[]
' ); + kate.setData( '
[Foo]
' ); + + john.type( ' Bar' ); + kate.unwrap(); + + syncClients(); + + expectClients( + '
Foo Bar
' + ); + } ); + it( 'element, then insert text and move', () => { john.setData( '
[]Foo
' ); kate.setData( '
[]Foo
' ); @@ -914,71 +984,6 @@ describe( 'transform', () => { } ); } ); - // This should be moved to attribute.js. - describe( 'by remove attribute', () => { - it( 'from element in different path', () => { - john.setData( '[]FooBar' ); - kate.setData( 'Foo[Bar]' ); - - john.type( 'Abc' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( 'AbcFooBar' ); - } ); - - it( 'from text in different path', () => { - john.setData( '[]Foo<$text bold="true">Bar' ); - kate.setData( 'Foo<$text bold="true">[Bar]' ); - - john.type( 'Abc' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( 'AbcFooBar' ); - } ); - - it( 'from text in same path', () => { - john.setData( '[]Fo<$text bold="true">o' ); - kate.setData( 'Fo<$text bold="true">[o]' ); - - john.type( 'Bar' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( 'BarFoo' ); - } ); - - it( 'from element in same path', () => { - john.setData( '[]Foo' ); - kate.setData( '[Foo]' ); - - john.type( 'Bar' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( 'BarFoo' ); - } ); - - it( 'from text with 2 attributes in same path', () => { - john.setData( '[]Fo<$text bold="true" italic="true">o' ); - kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); - - john.type( 'Bar' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'BarFo<$text italic="true">o' - ); - } ); - } ); - describe( 'by rename', () => { it( 'element in different path', () => { john.setData( 'FooBar[]' ); diff --git a/tests/model/operation/transform/marker.js b/tests/model/operation/transform/marker.js index 5fb5565d4..bd1b550ad 100644 --- a/tests/model/operation/transform/marker.js +++ b/tests/model/operation/transform/marker.js @@ -736,99 +736,6 @@ describe( 'transform', () => { } ); } ); - // Should be in attribute.js. - describe( 'by remove attribute', () => { - it( 'from element in different path', () => { - john.setData( '[Foo]Bar' ); - kate.setData( 'Foo[Bar]' ); - - john.setMarker( 'm1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' + - 'Bar' - ); - } ); - - it( 'from text in different path', () => { - john.setData( '[Foo]<$text bold="true">Bar' ); - kate.setData( 'Foo<$text bold="true">[Bar]' ); - - john.setMarker( 'm1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' + - 'Bar' - ); - } ); - - it( 'from text in same path', () => { - john.setData( '[Fo]<$text bold="true">o' ); - kate.setData( 'Fo<$text bold="true">[o]' ); - - john.setMarker( 'm1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' - ); - } ); - - it( 'from text in same path, then undo', () => { - john.setData( '[Fo]<$text bold="true">o' ); - kate.setData( 'Fo<$text bold="true">[o]' ); - - john.setMarker( 'm1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - kate.undo(); - - syncClients(); - - expectClients( - 'Fo<$text bold="true">o' - ); - } ); - - it( 'from text with 2 attributes in same path', () => { - john.setData( '[Fo]<$text bold="true" italic="true">o' ); - kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); - - john.setMarker( 'm1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Fo<$text italic="true">o' - ); - } ); - - it( 'from text in other user\'s selection', () => { - john.setData( '<$text bold="true">[Foo]' ); - kate.setData( '<$text bold="true">[Foo]' ); - - john.setMarker( 'm1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' - ); - } ); - } ); - describe( 'by merge', () => { it( 'element into paragraph', () => { john.setData( '[Foo] Bar' ); diff --git a/tests/model/operation/transform/move.js b/tests/model/operation/transform/move.js index 700ab6074..1978ac1ff 100644 --- a/tests/model/operation/transform/move.js +++ b/tests/model/operation/transform/move.js @@ -671,95 +671,6 @@ describe( 'transform', () => { } ); } ); - describe( 'by remove attribute', () => { - it( 'from element in different path', () => { - john.setData( 'F[oo]Bar' ); - kate.setData( 'Foo[Bar]' ); - - john.move( [ 1, 0 ] ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'F' + - 'ooBar' - ); - } ); - - it( 'from text in different path', () => { - john.setData( 'F[oo]Bar' ); - kate.setData( 'Foo[Bar]' ); - - john.move( [ 1, 0 ] ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'F' + - 'ooBar' - ); - } ); - - it( 'from text in same path', () => { - john.setData( '[Fo]<$text bold="true">o' ); - kate.setData( 'Fo<$text bold="true">[o]' ); - - john.move( [ 0, 3 ] ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'oFo' - ); - } ); - - it( 'from element in same path', () => { - john.setData( '[Fo]o' ); - kate.setData( '[Foo]' ); - - john.move( [ 0, 3 ] ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'oFo' - ); - } ); - - it( 'from text with 2 attributes in same path', () => { - john.setData( '[Fo]<$text bold="true" italic="true">o' ); - kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); - - john.move( [ 0, 3 ] ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - '<$text italic="true">oFo' - ); - } ); - - it( 'from text in other user\'s selection', () => { - john.setData( '<$text bold="true">[Foo]' ); - kate.setData( '<$text bold="true">[Foo]' ); - - john.move( [ 1, 0 ] ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - '' + - 'Foo' - ); - } ); - } ); - describe( 'by rename', () => { it( 'element in different path #1', () => { john.setData( 'FooB[ar]' ); diff --git a/tests/model/operation/transform/remove.js b/tests/model/operation/transform/remove.js index 7cc269e6e..96cfa300f 100644 --- a/tests/model/operation/transform/remove.js +++ b/tests/model/operation/transform/remove.js @@ -408,94 +408,6 @@ describe( 'transform', () => { } ); } ); - describe( 'by remove attribute', () => { - it( 'from element in different path', () => { - john.setData( 'F[oo]Bar' ); - kate.setData( 'Foo[Bar]' ); - - john.remove(); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'F' + - 'Bar' - ); - } ); - - it( 'from text in different path', () => { - john.setData( 'F[oo]<$text bold="true">Bar' ); - kate.setData( 'Foo<$text bold="true">[Bar]' ); - - john.remove(); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'F' + - 'Bar' - ); - } ); - - it( 'from text in same path', () => { - john.setData( '[Fo]<$text bold="true">o' ); - kate.setData( 'Fo<$text bold="true">[o]' ); - - john.remove(); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'o' - ); - } ); - - it( 'from element in same path', () => { - john.setData( '[Fo]o' ); - kate.setData( '[Foo]' ); - - john.remove(); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'o' - ); - } ); - - it( 'from text with 2 attributes in same path', () => { - john.setData( '[Fo]<$text bold="true" italic="true">o' ); - kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); - - john.remove(); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - '<$text italic="true">o' - ); - } ); - - it( 'from text in other user\'s selection', () => { - john.setData( '<$text bold="true">[Foo]' ); - kate.setData( '<$text bold="true">[Foo]' ); - - john.remove(); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - '' - ); - } ); - } ); - describe( 'by merge', () => { it( 'element into paragraph #1', () => { john.setData( 'F[oo]Bar' ); diff --git a/tests/model/operation/transform/rename.js b/tests/model/operation/transform/rename.js index f2aaa92d5..ec60a680c 100644 --- a/tests/model/operation/transform/rename.js +++ b/tests/model/operation/transform/rename.js @@ -15,94 +15,6 @@ describe( 'transform', () => { } ); describe( 'rename', () => { - describe( 'by remove attribute', () => { - it( 'from element in different path', () => { - john.setData( 'F[]ooBar' ); - kate.setData( 'Foo[Bar]' ); - - john.rename( 'heading1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' + - 'Bar' - ); - } ); - - it( 'from text in different path', () => { - john.setData( 'F[]ooBar' ); - kate.setData( 'Foo[Bar]' ); - - john.rename( 'heading1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' + - 'Bar' - ); - } ); - - it( 'from text in same path', () => { - john.setData( 'F[]o<$text bold="true">o' ); - kate.setData( 'Fo<$text bold="true">[o]' ); - - john.rename( 'heading1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' - ); - } ); - - it( 'from element in same path', () => { - john.setData( 'F[]oo' ); - kate.setData( '[Foo]' ); - - john.rename( 'heading1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' - ); - } ); - - it( 'from text with 2 attributes in same path', () => { - john.setData( 'F[o]<$text bold="true" italic="true">o' ); - kate.setData( 'Fo<$text bold="true" italic="true">[o]' ); - - john.rename( 'heading1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Fo<$text italic="true">o' - ); - } ); - - it( 'from text in other user\'s selection', () => { - john.setData( '<$text bold="true">[Foo]' ); - kate.setData( '<$text bold="true">[Foo]' ); - - john.rename( 'heading1' ); - kate.removeAttribute( 'bold' ); - - syncClients(); - - expectClients( - 'Foo' - ); - } ); - } ); - describe( 'by rename', () => { it( 'elements in different paths #1', () => { john.setData( '[]FooBar' ); From c68cb116005c91aa899c3e4e877901b37e1e4a2c Mon Sep 17 00:00:00 2001 From: Mgsy Date: Tue, 7 Aug 2018 16:30:04 +0200 Subject: [PATCH 4/5] Code style. --- tests/model/operation/transform/attribute.js | 104 +++++-------------- tests/model/operation/transform/insert.js | 36 ++----- tests/model/operation/transform/marker.js | 64 ++++-------- tests/model/operation/transform/move.js | 36 ++----- tests/model/operation/transform/remove.js | 64 +++--------- tests/model/operation/transform/rename.js | 20 +--- tests/model/operation/transform/split.js | 12 +-- 7 files changed, 86 insertions(+), 250 deletions(-) diff --git a/tests/model/operation/transform/attribute.js b/tests/model/operation/transform/attribute.js index fede8c4d6..faf8999c3 100644 --- a/tests/model/operation/transform/attribute.js +++ b/tests/model/operation/transform/attribute.js @@ -336,9 +336,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'BarFo<$text italic="true">o' - ); + expectClients( 'BarFo<$text italic="true">o' ); } ); } ); @@ -460,9 +458,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'oFo' - ); + expectClients( 'oFo' ); } ); it( 'remove attribute from element in same path', () => { @@ -474,9 +470,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'oFo' - ); + expectClients( 'oFo' ); } ); it( 'remove attribute from text with 2 attributes in same path', () => { @@ -488,9 +482,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text italic="true">oFo' - ); + expectClients( '<$text italic="true">oFo' ); } ); it( 'remove attribute from text in other user\'s selection', () => { @@ -655,9 +647,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text bold="true">Foo' - ); + expectClients( '<$text bold="true">Foo' ); } ); it( 'element in same path #2', () => { @@ -681,9 +671,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
<$text bold="true">Foo
' - ); + expectClients( '
<$text bold="true">Foo
' ); } ); } ); @@ -806,9 +794,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text bold="true">Fo' - ); + expectClients( '<$text bold="true">Fo' ); } ); it( 'text in other user\'s selection', () => { @@ -820,9 +806,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text bold="true">F' - ); + expectClients( '<$text bold="true">F' ); } ); it( 'remove attribute from element in different path', () => { @@ -864,9 +848,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'o' - ); + expectClients( 'o' ); } ); it( 'remove attribute from element in same path', () => { @@ -878,9 +860,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'o' - ); + expectClients( 'o' ); } ); it( 'remove attribute from text with 2 attributes in same path', () => { @@ -892,9 +872,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text italic="true">o' - ); + expectClients( '<$text italic="true">o' ); } ); it( 'remove attribute from text in other user\'s selection', () => { @@ -906,9 +884,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); } ); @@ -952,9 +928,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text bold="true">Foo' - ); + expectClients( '<$text bold="true">Foo' ); } ); it( 'from element in same path', () => { @@ -978,9 +952,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text bold="true">Fo<$text italic="true">o' - ); + expectClients( '<$text bold="true">Fo<$text italic="true">o' ); } ); it( 'from text in other user\'s selection', () => { @@ -992,9 +964,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text italic="true">Foo' - ); + expectClients( '<$text italic="true">Foo' ); } ); } ); @@ -1126,9 +1096,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'remove attribute from text in same path, then undo', () => { @@ -1144,9 +1112,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Fo<$text bold="true">o' - ); + expectClients( 'Fo<$text bold="true">o' ); } ); it( 'remove attribute from text with 2 attributes in same path', () => { @@ -1158,9 +1124,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Fo<$text italic="true">o' - ); + expectClients( 'Fo<$text italic="true">o' ); } ); it( 'remove attribute from text in other user\'s selection', () => { @@ -1172,9 +1136,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); } ); @@ -1234,9 +1196,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text bold="true">Foo Bar' - ); + expectClients( '<$text bold="true">Foo Bar' ); } ); it( 'element in user\'s selection', () => { @@ -1248,9 +1208,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '<$text bold="true">Foo' - ); + expectClients( '<$text bold="true">Foo' ); } ); it( 'element in user\'s selection, then undo', () => { @@ -1267,9 +1225,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'remove attribute from element in different path', () => { @@ -1311,9 +1267,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'remove attribute from element in same path', () => { @@ -1325,9 +1279,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'remove attribute from text with 2 attributes in same path', () => { @@ -1339,9 +1291,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Fo<$text italic="true">o' - ); + expectClients( 'Fo<$text italic="true">o' ); } ); it( 'remove attribute from text in other user\'s selection', () => { @@ -1353,9 +1303,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); } ); } ); diff --git a/tests/model/operation/transform/insert.js b/tests/model/operation/transform/insert.js index b3e1fb6e6..1969314f8 100644 --- a/tests/model/operation/transform/insert.js +++ b/tests/model/operation/transform/insert.js @@ -175,9 +175,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); } ); @@ -486,9 +484,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FooAbcBar' - ); + expectClients( 'FooAbcBar' ); } ); it( 'text in different path', () => { @@ -500,9 +496,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FooAbc
Bar
' - ); + expectClients( 'FooAbc
Bar
' ); } ); it( 'element in same path #1', () => { @@ -514,9 +508,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo Bar' - ); + expectClients( 'Foo Bar' ); } ); it( 'element in same path #2', () => { @@ -543,9 +535,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
Foo Bar
' - ); + expectClients( '
Foo Bar
' ); } ); it( 'element, then insert text and move', () => { @@ -770,9 +760,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FooAbc' - ); + expectClients( 'FooAbc' ); } ); it( 'text in same path', () => { @@ -784,9 +772,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Bar' - ); + expectClients( 'Bar' ); } ); it( 'element in different path', () => { @@ -931,9 +917,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo Bar' - ); + expectClients( 'Foo Bar' ); } ); } ); @@ -978,9 +962,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'BarFoo' - ); + expectClients( 'BarFoo' ); } ); } ); diff --git a/tests/model/operation/transform/marker.js b/tests/model/operation/transform/marker.js index bd1b550ad..47f40e0f2 100644 --- a/tests/model/operation/transform/marker.js +++ b/tests/model/operation/transform/marker.js @@ -159,9 +159,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); it.skip( 'then remove text and undo', () => { @@ -210,7 +208,9 @@ describe( 'transform', () => { syncClients(); expectClients( - 'Foo Bar' + '' + + 'Foo Bar' + + '' ); john.setSelection( [ 0, 1 ], [ 0, 3 ] ); @@ -221,9 +221,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'F oo' - ); + expectClients( 'F oo' ); } ); it( 'then unwrap and merge', () => { @@ -314,9 +312,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo Bar' - ); + expectClients( 'Foo Bar' ); } ); it( 'with the same name', () => { @@ -357,9 +353,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'oFo' - ); + expectClients( 'oFo' ); } ); it( 'text from other user\'s range #1', () => { @@ -373,9 +367,7 @@ describe( 'transform', () => { // Actual result for Kate: // BaFoo r - expectClients( - 'BaFoo r' - ); + expectClients( 'BaFoo r' ); } ); it( 'text from other user\'s range #2', () => { @@ -436,9 +428,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo ' - ); + expectClients( 'Foo ' ); } ); it( 'text in other user\'s selection #1', () => { @@ -450,9 +440,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'F' - ); + expectClients( 'F' ); } ); it( 'text in other user\'s selection #2', () => { @@ -464,9 +452,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); } ); @@ -608,9 +594,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'text in same path', () => { @@ -622,9 +606,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
Foo
' - ); + expectClients( '
Foo
' ); } ); it( 'element in same path, then undo', () => { @@ -640,9 +622,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'text in same path, then undo', () => { @@ -658,9 +638,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
Foo
' - ); + expectClients( '
Foo
' ); } ); } ); @@ -746,9 +724,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo Bar' - ); + expectClients( 'Foo Bar' ); } ); it( 'elements into paragraph', () => { @@ -766,9 +742,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo Bar Abc' - ); + expectClients( 'Foo Bar Abc' ); } ); it( 'wrapped element into wrapped paragraph', () => { @@ -813,9 +787,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); } ); } ); diff --git a/tests/model/operation/transform/move.js b/tests/model/operation/transform/move.js index 1978ac1ff..d59527dd2 100644 --- a/tests/model/operation/transform/move.js +++ b/tests/model/operation/transform/move.js @@ -338,9 +338,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'ooF' - ); + expectClients( 'ooF' ); } ); it( 'text in same path', () => { @@ -352,9 +350,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
ooF
' - ); + expectClients( '
ooF
' ); } ); } ); @@ -550,9 +546,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo Bar' - ); + expectClients( 'Foo Bar' ); } ); } ); @@ -566,9 +560,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'ooFBar' - ); + expectClients( 'ooFBar' ); } ); it( 'element into paragraph #2', () => { @@ -580,9 +572,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'arFooB' - ); + expectClients( 'arFooB' ); } ); it( 'element into paragraph #3', () => { @@ -594,9 +584,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FooBar' - ); + expectClients( 'FooBar' ); } ); it( 'wrapped element into wrapped paragraph #1', () => { @@ -608,9 +596,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
ooFBar
' - ); + expectClients( '
ooFBar
' ); } ); it( 'wrapped element into wrapped paragraph #2', () => { @@ -622,9 +608,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
arFooB
' - ); + expectClients( '
arFooB
' ); } ); it( 'wrapped element into wrapped paragraph #3', () => { @@ -636,9 +620,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
FooBar
' - ); + expectClients( '
FooBar
' ); } ); it( 'moved element', () => { diff --git a/tests/model/operation/transform/remove.js b/tests/model/operation/transform/remove.js index 96cfa300f..0fb5aaf65 100644 --- a/tests/model/operation/transform/remove.js +++ b/tests/model/operation/transform/remove.js @@ -25,9 +25,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FB' - ); + expectClients( 'FB' ); } ); it( 'text in same path', () => { @@ -39,9 +37,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'F B' - ); + expectClients( 'F B' ); } ); it( 'text in other user\'s selection #1', () => { @@ -53,9 +49,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); it( 'text in other user\'s selection #2', () => { @@ -67,9 +61,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); it( 'element in different path', () => { @@ -81,9 +73,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); it( 'text in other user\'s selection, then undo', () => { @@ -100,9 +90,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo Bar' - ); + expectClients( 'Foo Bar' ); } ); } ); @@ -148,9 +136,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
' - ); + expectClients( '
' ); } ); it( 'text in same path', () => { @@ -267,9 +253,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); it( 'text in same path', () => { @@ -281,9 +265,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
' - ); + expectClients( '
' ); } ); it( 'element while removing', () => { @@ -295,9 +277,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it.skip( 'element while removing, then undo', () => { @@ -402,9 +382,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); } ); @@ -418,9 +396,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FBar' - ); + expectClients( 'FBar' ); } ); it( 'element into paragraph #2', () => { @@ -432,9 +408,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FooB' - ); + expectClients( 'FooB' ); } ); it.skip( 'element into paragraph, then undo', () => { @@ -466,9 +440,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
FBar
' - ); + expectClients( '
FBar
' ); } ); it( 'wrapped element into wrapped paragraph #2', () => { @@ -480,9 +452,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
FooB
' - ); + expectClients( '
FooB
' ); } ); it( 'removed element, then undo', () => { @@ -540,9 +510,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '' - ); + expectClients( '' ); } ); } ); } ); diff --git a/tests/model/operation/transform/rename.js b/tests/model/operation/transform/rename.js index ec60a680c..1d59e11b0 100644 --- a/tests/model/operation/transform/rename.js +++ b/tests/model/operation/transform/rename.js @@ -210,9 +210,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'text in same path', () => { @@ -238,9 +236,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FooBar' - ); + expectClients( 'FooBar' ); } ); it( 'element into paragraph #2', () => { @@ -252,9 +248,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'FooBar' - ); + expectClients( 'FooBar' ); } ); it( 'wrapped element into wrapped paragraph #1', () => { @@ -266,9 +260,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
FooBar
' - ); + expectClients( '
FooBar
' ); } ); it( 'wrapped element into wrapped paragraph #2', () => { @@ -280,9 +272,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
FooBar
' - ); + expectClients( '
FooBar
' ); } ); } ); } ); diff --git a/tests/model/operation/transform/split.js b/tests/model/operation/transform/split.js index 9aa47c19e..7b621dc95 100644 --- a/tests/model/operation/transform/split.js +++ b/tests/model/operation/transform/split.js @@ -196,9 +196,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'text in same path, then undo', () => { @@ -214,9 +212,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - '
Foo
' - ); + expectClients( '
Foo
' ); } ); it( 'multiple elements', () => { @@ -297,9 +293,7 @@ describe( 'transform', () => { syncClients(); - expectClients( - 'Foo' - ); + expectClients( 'Foo' ); } ); it( 'text in different path', () => { From e5b3ed4959ad61d826410ab0a84a7a68c43a275b Mon Sep 17 00:00:00 2001 From: Mgsy Date: Wed, 8 Aug 2018 10:16:33 +0200 Subject: [PATCH 5/5] Added: New scenarios. --- tests/model/operation/transform/move.js | 30 ++++++++++++++++++++++- tests/model/operation/transform/remove.js | 12 +++++++++ tests/model/operation/transform/wrap.js | 30 ++++++++++++++++++++++- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/tests/model/operation/transform/move.js b/tests/model/operation/transform/move.js index d59527dd2..da9501b92 100644 --- a/tests/model/operation/transform/move.js +++ b/tests/model/operation/transform/move.js @@ -252,7 +252,7 @@ describe( 'transform', () => { ); } ); - it( 'element while moving', () => { + it( 'text while moving', () => { john.setData( '[Foo]Bar' ); kate.setData( '[Foo]Bar' ); @@ -651,6 +651,34 @@ describe( 'transform', () => { expectClients( 'FooBar' ); } ); + + it( 'moved text', () => { + john.setData( 'FooB[ar]' ); + kate.setData( 'Foo[]Bar' ); + + john.move( [ 0, 0 ] ); + kate.merge(); + + syncClients(); + + expectClients( 'arFooB' ); + } ); + + it( 'moved text, then undo', () => { + john.setData( 'FooB[ar]' ); + kate.setData( 'Foo[]Bar' ); + + john.move( [ 0, 0 ] ); + kate.merge(); + + syncClients(); + + john.undo(); + + syncClients(); + + expectClients( 'FooBar' ); + } ); } ); describe( 'by rename', () => { diff --git a/tests/model/operation/transform/remove.js b/tests/model/operation/transform/remove.js index 0fb5aaf65..630db6bce 100644 --- a/tests/model/operation/transform/remove.js +++ b/tests/model/operation/transform/remove.js @@ -268,6 +268,18 @@ describe( 'transform', () => { expectClients( '
' ); } ); + it( 'text in same path, then undo', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.remove(); + kate.unwrap(); + + syncClients(); + + expectClients( '
Foo
' ); + } ); + it( 'element while removing', () => { john.setData( 'Foo
[Bar]
' ); kate.setData( 'Foo
[Bar]
' ); diff --git a/tests/model/operation/transform/wrap.js b/tests/model/operation/transform/wrap.js index ef6ec22cc..fbcd1e276 100644 --- a/tests/model/operation/transform/wrap.js +++ b/tests/model/operation/transform/wrap.js @@ -211,10 +211,26 @@ describe( 'transform', () => { expectClients( '
Foo
' ); } ); + + it( 'the same text, then undo', () => { + john.setData( '
[Foo]
' ); + kate.setData( '
[Foo]
' ); + + john.wrap( 'div' ); + kate.unwrap(); + + syncClients(); + + kate.undo(); + + syncClients(); + + expectClients( '
Foo
' ); + } ); } ); describe( 'by delete', () => { - it( 'text in two elements', () => { + it( 'text in two elements #1', () => { john.setData( '[Foo]Bar' ); kate.setData( 'Fo[oBa]r' ); @@ -229,6 +245,18 @@ describe( 'transform', () => { '' ); } ); + + it( 'text in two elements #2', () => { + john.setData( '[Foo]Bar' ); + kate.setData( 'Fo[oBa]r' ); + + john.wrap( 'div' ); + kate.delete(); + + syncClients(); + + expectClients( '
Fo
r
' ); + } ); } ); describe( 'by merge', () => {