|
|
@@ -25,26 +25,27 @@ describe( 'ContextualToolbar', () => {
|
|
|
editorElement = document.createElement( 'div' );
|
|
|
document.body.appendChild( editorElement );
|
|
|
|
|
|
- return ClassicTestEditor.create( editorElement, {
|
|
|
- plugins: [ Paragraph, Bold, Italic, ContextualToolbar ],
|
|
|
- contextualToolbar: [ 'bold', 'italic' ]
|
|
|
- } )
|
|
|
- .then( newEditor => {
|
|
|
- newEditor.editing.view.attachDomRoot( editorElement );
|
|
|
-
|
|
|
- editor = newEditor;
|
|
|
- contextualToolbar = editor.plugins.get( ContextualToolbar );
|
|
|
- balloon = editor.plugins.get( ContextualBalloon );
|
|
|
-
|
|
|
- // There is no point to execute BalloonPanelView attachTo and pin methods so lets override it.
|
|
|
- sandbox.stub( balloon.view, 'attachTo', () => {} );
|
|
|
- sandbox.stub( balloon.view, 'pin', () => {} );
|
|
|
-
|
|
|
- // Focus the engine.
|
|
|
- editor.editing.view.isFocused = true;
|
|
|
+ return ClassicTestEditor
|
|
|
+ .create( editorElement, {
|
|
|
+ plugins: [ Paragraph, Bold, Italic, ContextualToolbar ],
|
|
|
+ contextualToolbar: [ 'bold', 'italic' ]
|
|
|
+ } )
|
|
|
+ .then( newEditor => {
|
|
|
+ newEditor.editing.view.attachDomRoot( editorElement );
|
|
|
+
|
|
|
+ editor = newEditor;
|
|
|
+ contextualToolbar = editor.plugins.get( ContextualToolbar );
|
|
|
+ balloon = editor.plugins.get( ContextualBalloon );
|
|
|
+
|
|
|
+ // There is no point to execute BalloonPanelView attachTo and pin methods so lets override it.
|
|
|
+ sandbox.stub( balloon.view, 'attachTo' ).returns( {} );
|
|
|
+ sandbox.stub( balloon.view, 'pin' ).returns( {} );
|
|
|
+
|
|
|
+ // Focus the engine.
|
|
|
+ editor.editing.view.isFocused = true;
|
|
|
|
|
|
- contextualToolbar.toolbarView.init();
|
|
|
- } );
|
|
|
+ contextualToolbar.toolbarView.init();
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
afterEach( () => {
|
|
|
@@ -276,7 +277,7 @@ describe( 'ContextualToolbar', () => {
|
|
|
let removeBalloonSpy;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
- removeBalloonSpy = sandbox.stub( balloon, 'remove', () => {} );
|
|
|
+ removeBalloonSpy = sandbox.stub( balloon, 'remove' ).returns( {} );
|
|
|
editor.editing.view.isFocused = true;
|
|
|
} );
|
|
|
|
|
|
@@ -397,8 +398,7 @@ describe( 'ContextualToolbar', () => {
|
|
|
|
|
|
contextualToolbar.fire( '_selectionChangeDebounced' );
|
|
|
|
|
|
- // Stubbing getters doesn't wor for sandbox.
|
|
|
- const stub = sinon.stub( balloon, 'visibleView', { get: () => contextualToolbar.toolbarView } );
|
|
|
+ const stub = sinon.stub( balloon, 'visibleView' ).get( () => contextualToolbar.toolbarView );
|
|
|
|
|
|
sinon.assert.calledOnce( showPanelSpy );
|
|
|
sinon.assert.notCalled( hidePanelSpy );
|
|
|
@@ -416,8 +416,7 @@ describe( 'ContextualToolbar', () => {
|
|
|
|
|
|
contextualToolbar.fire( '_selectionChangeDebounced' );
|
|
|
|
|
|
- // Stubbing getters doesn't wor for sandbox.
|
|
|
- const stub = sinon.stub( balloon, 'visibleView', { get: () => null } );
|
|
|
+ const stub = sinon.stub( balloon, 'visibleView' ).get( () => null );
|
|
|
|
|
|
sinon.assert.calledOnce( showPanelSpy );
|
|
|
sinon.assert.notCalled( hidePanelSpy );
|
|
|
@@ -459,7 +458,7 @@ describe( 'ContextualToolbar', () => {
|
|
|
const originalViewRangeToDom = editingView.domConverter.viewRangeToDom;
|
|
|
|
|
|
// Mock selection rect.
|
|
|
- sandbox.stub( editingView.domConverter, 'viewRangeToDom', ( ...args ) => {
|
|
|
+ sandbox.stub( editingView.domConverter, 'viewRangeToDom' ).callsFake( ( ...args ) => {
|
|
|
const domRange = originalViewRangeToDom.apply( editingView.domConverter, args );
|
|
|
|
|
|
sandbox.stub( domRange, 'getClientRects' )
|