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

Tests: New cases which include ranges in blocks in OT tests #1494

Merged
merged 13 commits into from
Aug 16, 2018
477 changes: 454 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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you removed those tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved all remove attribute tests to the attribute.js file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, didn't see that cause attribute.js was not expanded. What about the wrap test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I see that wrap, unwrap and split don't have this kind of tests. I'll add them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've meant that there is a removed test in move.js: 'intersecting wrap'. I've commented on that below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I see that wrap, unwrap and split don't have this kind of tests. I'll add them.

Done.

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