瀏覽代碼

Fixed failing tests on Safari.

Szymon Kupś 8 年之前
父節點
當前提交
97aaf06f9a
共有 1 個文件被更改,包括 8 次插入5 次删除
  1. 8 5
      packages/ckeditor5-ui/tests/toolbar/contextual/contextualtoolbar.js

+ 8 - 5
packages/ckeditor5-ui/tests/toolbar/contextual/contextualtoolbar.js

@@ -15,7 +15,7 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
 
 
-/* global document, setTimeout */
+/* global document, setTimeout, window */
 
 
 describe( 'ContextualToolbar', () => {
 describe( 'ContextualToolbar', () => {
 	let sandbox, editor, contextualToolbar, balloon, editorElement;
 	let sandbox, editor, contextualToolbar, balloon, editorElement;
@@ -44,6 +44,9 @@ describe( 'ContextualToolbar', () => {
 
 
 				// Focus the engine.
 				// Focus the engine.
 				editor.editing.view.isFocused = true;
 				editor.editing.view.isFocused = true;
+
+				// Remove all selection ranges from DOM before testing.
+				window.getSelection().removeAllRanges();
 			} );
 			} );
 	} );
 	} );
 
 
@@ -284,7 +287,7 @@ describe( 'ContextualToolbar', () => {
 			let showSpy;
 			let showSpy;
 
 
 			beforeEach( () => {
 			beforeEach( () => {
-				showSpy = sinon.spy( contextualToolbar, 'show' );
+				showSpy = sandbox.spy( contextualToolbar, 'show' );
 			} );
 			} );
 
 
 			it( 'should not be called when the editor is not focused', () => {
 			it( 'should not be called when the editor is not focused', () => {
@@ -437,7 +440,7 @@ describe( 'ContextualToolbar', () => {
 
 
 			contextualToolbar.fire( '_selectionChangeDebounced' );
 			contextualToolbar.fire( '_selectionChangeDebounced' );
 
 
-			const stub = sinon.stub( balloon, 'visibleView' ).get( () => contextualToolbar.toolbarView );
+			const stub = sandbox.stub( balloon, 'visibleView' ).get( () => contextualToolbar.toolbarView );
 
 
 			sinon.assert.calledOnce( showPanelSpy );
 			sinon.assert.calledOnce( showPanelSpy );
 			sinon.assert.notCalled( hidePanelSpy );
 			sinon.assert.notCalled( hidePanelSpy );
@@ -455,7 +458,7 @@ describe( 'ContextualToolbar', () => {
 
 
 			contextualToolbar.fire( '_selectionChangeDebounced' );
 			contextualToolbar.fire( '_selectionChangeDebounced' );
 
 
-			const stub = sinon.stub( balloon, 'visibleView' ).get( () => null );
+			const stub = sandbox.stub( balloon, 'visibleView' ).get( () => null );
 
 
 			sinon.assert.calledOnce( showPanelSpy );
 			sinon.assert.calledOnce( showPanelSpy );
 			sinon.assert.notCalled( hidePanelSpy );
 			sinon.assert.notCalled( hidePanelSpy );
@@ -471,7 +474,7 @@ describe( 'ContextualToolbar', () => {
 
 
 	describe( 'show event', () => {
 	describe( 'show event', () => {
 		it( 'should fire `show` event just before panel shows', () => {
 		it( 'should fire `show` event just before panel shows', () => {
-			const spy = sinon.spy();
+			const spy = sandbox.spy();
 
 
 			contextualToolbar.on( 'show', spy );
 			contextualToolbar.on( 'show', spy );
 			setData( editor.document, '<paragraph>b[a]r</paragraph>' );
 			setData( editor.document, '<paragraph>b[a]r</paragraph>' );