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

Commit

Permalink
Merge pull request #1494 from ckeditor/t/1470
Browse files Browse the repository at this point in the history
Tests: New scenarios in OT tests, which include ranges in blocks.
  • Loading branch information
scofalik authored Aug 16, 2018
2 parents 27ab310 + dfa206c commit c6014a4
Show file tree
Hide file tree
Showing 9 changed files with 1,079 additions and 608 deletions.
714 changes: 691 additions & 23 deletions tests/model/operation/transform/attribute.js

Large diffs are not rendered by default.

140 changes: 50 additions & 90 deletions tests/model/operation/transform/insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ describe( 'transform', () => {

syncClients();

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

Expand Down Expand Up @@ -216,6 +214,21 @@ describe( 'transform', () => {
);
} );

it( 'text at different paths', () => {
john.setData( '<paragraph>[]Foo</paragraph><paragraph>Bar</paragraph>' );
kate.setData( '<paragraph>Foo</paragraph><paragraph>B[ar]</paragraph>' );

john.type( 'Abc' );
kate.move( [ 1, 0 ] );

syncClients();

expectClients(
'<paragraph>AbcFoo</paragraph>' +
'<paragraph>arB</paragraph>'
);
} );

it( 'text at same path', () => {
john.setData( '<paragraph>F[]oo Bar</paragraph>' );
kate.setData( '<paragraph>Foo B[ar]</paragraph>' );
Expand Down Expand Up @@ -254,7 +267,7 @@ describe( 'transform', () => {
} );

describe( 'by wrap', () => {
it( 'element in same path', () => {
it( 'element in same path #1', () => {
john.setData( '<paragraph>Foo Bar</paragraph>[]' );
kate.setData( '[<paragraph>Foo Bar</paragraph>]' );

Expand All @@ -271,7 +284,7 @@ describe( 'transform', () => {
);
} );

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

Expand All @@ -287,7 +300,7 @@ describe( 'transform', () => {
);
} );

it( 'element in different paths', () => {
it( 'element in different paths #1', () => {
john.setData( '<paragraph>Foo</paragraph>[]<paragraph>Bar</paragraph>' );
kate.setData( '<paragraph>Foo</paragraph>[<paragraph>Bar</paragraph>]' );

Expand All @@ -305,7 +318,7 @@ describe( 'transform', () => {
);
} );

it( 'element in different paths', () => {
it( 'element in different paths #2', () => {
john.setData( '<paragraph>Foo</paragraph><paragraph>Bar[]</paragraph>' );
kate.setData( '[<paragraph>Foo</paragraph>]<paragraph>Bar</paragraph>' );

Expand Down Expand Up @@ -444,9 +457,19 @@ describe( 'transform', () => {

syncClients();

expectClients(
'<paragraph>FooAbc</paragraph><paragraph>Bar</paragraph>'
);
expectClients( '<paragraph>FooAbc</paragraph><paragraph>Bar</paragraph>' );
} );

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>' );

john.type( 'Abc' );
kate.unwrap();

syncClients();

expectClients( '<paragraph>FooAbc</paragraph><blockQuote>Bar</blockQuote>' );
} );

it( 'element in same path #1', () => {
Expand All @@ -458,9 +481,7 @@ describe( 'transform', () => {

syncClients();

expectClients(
'<paragraph>Foo Bar</paragraph>'
);
expectClients( '<paragraph>Foo Bar</paragraph>' );
} );

it( 'element in same path #2', () => {
Expand All @@ -478,6 +499,18 @@ describe( 'transform', () => {
);
} );

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

john.type( ' Bar' );
kate.unwrap();

syncClients();

expectClients( '<blockQuote>Foo Bar</blockQuote>' );
} );

it( 'element, then insert text and move', () => {
john.setData( '<blockQuote>[]<paragraph>Foo</paragraph></blockQuote>' );
kate.setData( '<blockQuote>[]<paragraph>Foo</paragraph></blockQuote>' );
Expand Down Expand Up @@ -700,9 +733,7 @@ describe( 'transform', () => {

syncClients();

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

it( 'text in same path', () => {
Expand All @@ -714,9 +745,7 @@ describe( 'transform', () => {

syncClients();

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

it( 'element in different path', () => {
Expand Down Expand Up @@ -859,9 +888,7 @@ describe( 'transform', () => {

syncClients();

expectClients(
'<paragraph>Foo Bar</paragraph>'
);
expectClients( '<paragraph>Foo Bar</paragraph>' );
} );
} );

Expand Down Expand Up @@ -906,74 +933,7 @@ describe( 'transform', () => {

syncClients();

expectClients(
'<paragraph>BarFo<m1:start></m1:start>o<m1:end></m1:end></paragraph>'
);
} );
} );

// This should be moved to attribute.js.
describe( 'by remove attribute', () => {
it( 'from element in different path', () => {
john.setData( '<paragraph>[]Foo</paragraph><paragraph bold="true">Bar</paragraph>' );
kate.setData( '<paragraph>Foo</paragraph>[<paragraph bold="true">Bar</paragraph>]' );

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

syncClients();

expectClients( '<paragraph>AbcFoo</paragraph><paragraph>Bar</paragraph>' );
} );

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

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

syncClients();

expectClients( '<paragraph>AbcFoo</paragraph><paragraph>Bar</paragraph>' );
} );

it( '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.type( 'Bar' );
kate.removeAttribute( 'bold' );

syncClients();

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

it( 'from element in same path', () => {
john.setData( '<paragraph bold="true">[]Foo</paragraph>' );
kate.setData( '[<paragraph bold="true">Foo</paragraph>]' );

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

syncClients();

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

it( '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.type( 'Bar' );
kate.removeAttribute( 'bold' );

syncClients();

expectClients(
'<paragraph>BarFo<$text italic="true">o</$text></paragraph>'
);
expectClients( '<paragraph>BarFo<m1:start></m1:start>o<m1:end></m1:end></paragraph>' );
} );
} );

Expand Down
Loading

0 comments on commit c6014a4

Please sign in to comment.