Browse Source

Added tests to DocumentSelection.

Szymon Kupś 7 years ago
parent
commit
5a1892d952

File diff suppressed because it is too large
+ 1124 - 0
packages/ckeditor5-engine/tests/view/documentselection.js


+ 9 - 0
packages/ckeditor5-engine/tests/view/selection.js

@@ -4,6 +4,7 @@
  */
  */
 
 
 import Selection from '../../src/view/selection';
 import Selection from '../../src/view/selection';
+import DocumentSelection from '../../src/view/documentselection';
 import Range from '../../src/view/range';
 import Range from '../../src/view/range';
 import Document from '../../src/view/document';
 import Document from '../../src/view/document';
 import Element from '../../src/view/element';
 import Element from '../../src/view/element';
@@ -92,6 +93,14 @@ describe( 'Selection', () => {
 			expect( selection.isBackward ).to.be.true;
 			expect( selection.isBackward ).to.be.true;
 		} );
 		} );
 
 
+		it( 'should be able to create a selection from the other document selection', () => {
+			const otherSelection = new DocumentSelection( [ range2, range3 ], { backward: true } );
+			const selection = new Selection( otherSelection );
+
+			expect( Array.from( selection.getRanges() ) ).to.deep.equal( [ range2, range3 ] );
+			expect( selection.isBackward ).to.be.true;
+		} );
+
 		it( 'should be able to create a fake selection from the other fake selection', () => {
 		it( 'should be able to create a fake selection from the other fake selection', () => {
 			const otherSelection = new Selection( [ range2, range3 ], { fake: true, label: 'foo bar baz' } );
 			const otherSelection = new Selection( [ range2, range3 ], { fake: true, label: 'foo bar baz' } );
 			const selection = new Selection( otherSelection );
 			const selection = new Selection( otherSelection );