|
@@ -276,35 +276,11 @@ describe( 'LiveSelection', () => {
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- describe( 'getSnapshot', () => {
|
|
|
|
|
- it( 'should return a Selection instance with default range if no ranges were added', () => {
|
|
|
|
|
- const snapshot = selection.getSnapshot();
|
|
|
|
|
-
|
|
|
|
|
- expect( selection.isBackward ).to.equal( snapshot.isBackward );
|
|
|
|
|
-
|
|
|
|
|
- const snapshotRanges = Array.from( snapshot.getRanges() );
|
|
|
|
|
-
|
|
|
|
|
- expect( snapshotRanges.length ).to.equal( 1 );
|
|
|
|
|
- expect( snapshotRanges[ 0 ].start.path ).to.deep.equal( [ 0, 0 ] );
|
|
|
|
|
- expect( snapshotRanges[ 0 ].end.path ).to.deep.equal( [ 0, 0 ] );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should return a Selection instance with same ranges and direction as this selection', () => {
|
|
|
|
|
- selection.addRange( liveRange );
|
|
|
|
|
|
|
+ describe( 'createFromSelection', () => {
|
|
|
|
|
+ it( 'should return a LiveSelection instance', () => {
|
|
|
selection.addRange( range, true );
|
|
selection.addRange( range, true );
|
|
|
|
|
|
|
|
- const snapshot = selection.getSnapshot();
|
|
|
|
|
-
|
|
|
|
|
- expect( selection.isBackward ).to.equal( snapshot.isBackward );
|
|
|
|
|
-
|
|
|
|
|
- const selectionRanges = Array.from( selection.getRanges() );
|
|
|
|
|
- const snapshotRanges = Array.from( snapshot.getRanges() );
|
|
|
|
|
-
|
|
|
|
|
- expect( selectionRanges.length ).to.equal( snapshotRanges.length );
|
|
|
|
|
-
|
|
|
|
|
- for ( let i = 0; i < selectionRanges.length; i++ ) {
|
|
|
|
|
- expect( selectionRanges[ i ].isEqual( snapshotRanges[ i ] ) ).to.be.true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ expect( LiveSelection.createFromSelection( selection ) ).to.be.instanceof( LiveSelection );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
|