|
|
@@ -19,6 +19,7 @@ import DomConverter from '../../../src/view/domconverter';
|
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
import count from '@ckeditor/ckeditor5-utils/src/count';
|
|
|
import log from '@ckeditor/ckeditor5-utils/src/log';
|
|
|
+import global from '@ckeditor/ckeditor5-utils/src/dom/global';
|
|
|
|
|
|
testUtils.createSinonSandbox();
|
|
|
|
|
|
@@ -323,6 +324,26 @@ describe( 'Document', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
+ describe( 'scrollToTheSelection()', () => {
|
|
|
+ it( 'does nothing when there are no ranges in the selection', () => {
|
|
|
+ const stub = testUtils.sinon.stub( global.window, 'scrollTo' );
|
|
|
+
|
|
|
+ viewDocument.scrollToTheSelection();
|
|
|
+ sinon.assert.notCalled( stub );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'scrolls to the first range in selection with an offset', () => {
|
|
|
+ const stub = testUtils.sinon.stub( global.window, 'scrollTo' );
|
|
|
+ const root = viewDocument.createRoot( document.createElement( 'div' ) );
|
|
|
+ const range = ViewRange.createIn( root );
|
|
|
+
|
|
|
+ viewDocument.selection.addRange( range );
|
|
|
+
|
|
|
+ viewDocument.scrollToTheSelection();
|
|
|
+ sinon.assert.calledWithMatch( stub, sinon.match.number, sinon.match.number );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
describe( 'disableObservers()', () => {
|
|
|
it( 'should disable observers', () => {
|
|
|
const addedObserverMock = viewDocument.addObserver( ObserverMock );
|