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

Commit

Permalink
Improved scenarios and code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgsy committed Aug 9, 2018
1 parent e5b3ed4 commit d35441d
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 34 deletions.
50 changes: 39 additions & 11 deletions tests/model/operation/transform/attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ describe( 'transform', () => {
} );

it( 'remove attribute from text in same path', () => {
john.setData( '<paragraph>[]Fo<$text bold="true">o</$text></paragraph>' );
kate.setData( '<paragraph>Fo<$text bold="true">[o]</$text></paragraph>' );
john.setData( '<paragraph>F<$text bold="true">o[]o</$text></paragraph>' );
kate.setData( '<paragraph>F<$text bold="true">[oo]</$text></paragraph>' );

john.type( 'Bar' );
kate.removeAttribute( 'bold' );

syncClients();

expectClients( '<paragraph>BarFoo</paragraph>' );
expectClients( '<paragraph>FoBaro</paragraph>' );
} );

it( 'remove attribute from element in same path', () => {
Expand All @@ -328,15 +328,15 @@ describe( 'transform', () => {
} );

it( 'remove attribute from text with 2 attributes in same path', () => {
john.setData( '<paragraph>[]Fo<$text bold="true" italic="true">o</$text></paragraph>' );
kate.setData( '<paragraph>Fo<$text bold="true" italic="true">[o]</$text></paragraph>' );
john.setData( '<paragraph>F<$text bold="true" italic="true">o[]o</$text></paragraph>' );
kate.setData( '<paragraph>F<$text bold="true" italic="true">[oo]</$text></paragraph>' );

john.type( 'Bar' );
kate.removeAttribute( 'bold' );

syncClients();

expectClients( '<paragraph>BarFo<$text italic="true">o</$text></paragraph>' );
expectClients( '<paragraph>F<$text italic="true">oBaro</$text></paragraph>' );
} );
} );

Expand Down Expand Up @@ -435,8 +435,8 @@ describe( 'transform', () => {
} );

it( 'remove attribute from text in different path', () => {
john.setData( '<paragraph>F[oo]</paragraph><paragraph>Bar</paragraph>' );
kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
john.setData( '<paragraph>F[oo]</paragraph><paragraph><$text bold="true">Bar</$text></paragraph>' );
kate.setData( '<paragraph>Foo</paragraph><paragraph><$text bold="true">[Bar]</$text></paragraph>' );

john.move( [ 1, 0 ] );
kate.removeAttribute( 'bold' );
Expand Down Expand Up @@ -625,7 +625,7 @@ describe( 'transform', () => {

it( 'text in different path', () => {
john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[]Bar</paragraph></blockQuote>' );

john.setAttribute( 'bold', true );
kate.unwrap();
Expand Down Expand Up @@ -839,7 +839,7 @@ describe( 'transform', () => {
);
} );

it( 'remove attribute from text in same path', () => {
it( 'remove attribute from text in same path #1', () => {
john.setData( '<paragraph>[Fo]<$text bold="true">o</$text></paragraph>' );
kate.setData( '<paragraph>Fo<$text bold="true">[o]</$text></paragraph>' );

Expand All @@ -851,6 +851,20 @@ describe( 'transform', () => {
expectClients( '<paragraph>o</paragraph>' );
} );

it( 'remove attribute from text in same path #2', () => {
john.setData( '<paragraph>F[o<$text bold="true">o]z</$text>Bar</paragraph>' );
kate.setData( '<paragraph>Fo<$text bold="true">[oz]</$text>Bar</paragraph>' );

john.remove();
kate.removeAttribute( 'bold' );

syncClients();

expectClients(
'<paragraph>FzBar</paragraph>'
);
} );

it( 'remove attribute from element in same path', () => {
john.setData( '<paragraph bold="true">[Fo]o</paragraph>' );
kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );
Expand All @@ -863,7 +877,7 @@ describe( 'transform', () => {
expectClients( '<paragraph>o</paragraph>' );
} );

it( 'remove attribute from text with 2 attributes in same path', () => {
it( 'remove attribute from text with 2 attributes in same path #1', () => {
john.setData( '<paragraph>[Fo]<$text bold="true" italic="true">o</$text></paragraph>' );
kate.setData( '<paragraph>Fo<$text bold="true" italic="true">[o]</$text></paragraph>' );

Expand All @@ -875,6 +889,20 @@ describe( 'transform', () => {
expectClients( '<paragraph><$text italic="true">o</$text></paragraph>' );
} );

it( 'remove attribute from text with 2 attributes in same path #2', () => {
john.setData( '<paragraph>F[o<$text bold="true" italic="true">o]z</$text>Bar</paragraph>' );
kate.setData( '<paragraph>Fo<$text bold="true" italic="true">[oz]</$text>Bar</paragraph>' );

john.remove();
kate.removeAttribute( 'bold' );

syncClients();

expectClients(
'<paragraph>F<$text italic="true">z</$text>Bar</paragraph>'
);
} );

it( 'remove attribute from text in other user\'s selection', () => {
john.setData( '<paragraph><$text bold="true">[Foo]</$text></paragraph>' );
kate.setData( '<paragraph><$text bold="true">[Foo]</$text></paragraph>' );
Expand Down
4 changes: 2 additions & 2 deletions tests/model/operation/transform/insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ describe( 'transform', () => {

it( 'text in different path', () => {
john.setData( '<paragraph>Foo[]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[]Bar</paragraph></blockQuote>' );

john.type( 'Abc' );
kate.unwrap();
Expand Down Expand Up @@ -528,7 +528,7 @@ describe( 'transform', () => {

it( 'text in same path', () => {
john.setData( '<blockQuote><paragraph>Foo[]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.type( ' Bar' );
kate.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions tests/model/operation/transform/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ describe( 'transform', () => {

it( 'text in different path', () => {
john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[]Bar</paragraph></blockQuote>' );

john.setMarker( 'm1' );
kate.unwrap();
Expand All @@ -599,7 +599,7 @@ describe( 'transform', () => {

it( 'text in same path', () => {
john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.setMarker( 'm1' );
kate.unwrap();
Expand Down Expand Up @@ -627,7 +627,7 @@ describe( 'transform', () => {

it( 'text in same path, then undo', () => {
john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.setMarker( 'm1' );
kate.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions tests/model/operation/transform/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe( 'transform', () => {

it( 'text in different path', () => {
john.setData( '<paragraph>F[oo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[]Bar</paragraph></blockQuote>' );

john.move( [ 0, 0 ] );
kate.unwrap();
Expand All @@ -343,7 +343,7 @@ describe( 'transform', () => {

it( 'text in same path', () => {
john.setData( '<blockQuote><paragraph>F[oo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.move( [ 0, 0, 0 ] );
kate.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions tests/model/operation/transform/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ describe( 'transform', () => {

it( 'text in different path', () => {
john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[]Bar</paragraph></blockQuote>' );

john.remove();
kate.unwrap();
Expand All @@ -258,7 +258,7 @@ describe( 'transform', () => {

it( 'text in same path', () => {
john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.remove();
kate.unwrap();
Expand All @@ -270,7 +270,7 @@ describe( 'transform', () => {

it( 'text in same path, then undo', () => {
john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.remove();
kate.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions tests/model/operation/transform/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe( 'transform', () => {

it( 'text in different path', () => {
john.setData( '<paragraph>F[]oo</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[]Bar</paragraph></blockQuote>' );

john.rename( 'heading1' );
kate.unwrap();
Expand All @@ -215,7 +215,7 @@ describe( 'transform', () => {

it( 'text in same path', () => {
john.setData( '<blockQuote><paragraph>F[]oo</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.rename( 'heading1' );
kate.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions tests/model/operation/transform/split.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe( 'transform', () => {

it( 'text in same path', () => {
john.setData( '<blockQuote><paragraph>F[]oo</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.split();
kate.unwrap();
Expand Down Expand Up @@ -201,7 +201,7 @@ describe( 'transform', () => {

it( 'text in same path, then undo', () => {
john.setData( '<blockQuote><paragraph>F[]oo</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.split();
kate.unwrap();
Expand Down
12 changes: 6 additions & 6 deletions tests/model/operation/transform/unwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ describe( 'transform', () => {

it( 'text in different path', () => {
john.setData(
'<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' +
'<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' +
'<blockQuote><paragraph>Bar</paragraph></blockQuote>'
);

kate.setData(
'<blockQuote><paragraph>Foo</paragraph></blockQuote>' +
'<blockQuote><paragraph>[Bar]</paragraph></blockQuote>'
'<blockQuote><paragraph>[]Bar</paragraph></blockQuote>'
);

john.unwrap();
Expand Down Expand Up @@ -92,8 +92,8 @@ describe( 'transform', () => {
} );

it( 'the same text', () => {
john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
john.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.unwrap();
kate.unwrap();
Expand All @@ -104,8 +104,8 @@ describe( 'transform', () => {
} );

it( 'the same text, then undo', () => {
john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
john.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.unwrap();
kate.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions tests/model/operation/transform/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe( 'transform', () => {

it( 'text in different path', () => {
john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[]Bar</paragraph></blockQuote>' );

john.wrap( 'div' );
kate.unwrap();
Expand Down Expand Up @@ -202,7 +202,7 @@ describe( 'transform', () => {

it( 'the same text', () => {
john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.wrap( 'div' );
kate.unwrap();
Expand All @@ -214,7 +214,7 @@ describe( 'transform', () => {

it( 'the same text, then undo', () => {
john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );

john.wrap( 'div' );
kate.unwrap();
Expand Down

0 comments on commit d35441d

Please sign in to comment.