Преглед на файлове

ImageBalloonPanel init() method should return a promise.

Szymon Kupś преди 9 години
родител
ревизия
4a6d002ef3
променени са 2 файла, в които са добавени 16 реда и са изтрити 5 реда
  1. 2 2
      packages/ckeditor5-image/src/ui/imageballoonpanelview.js
  2. 14 3
      packages/ckeditor5-image/tests/ui/imageballoonpanelview.js

+ 2 - 2
packages/ckeditor5-image/src/ui/imageballoonpanelview.js

@@ -86,10 +86,10 @@ export default class ImageBalloonPanelView extends BalloonPanelView {
 	 * @inheritDoc
 	 */
 	init() {
-		super.init();
-
 		// Let the focusTracker know about new focusable UI element.
 		this.editor.ui.focusTracker.add( this.element );
+
+		return super.init();
 	}
 
 	/**

+ 14 - 3
packages/ckeditor5-image/tests/ui/imageballoonpanelview.js

@@ -36,14 +36,25 @@ describe( 'ImageBalloonPanel', () => {
 		return editor.destroy();
 	} );
 
+	it( 'init method should return a promise', () => {
+		const panel = new ImageBalloonPanel( editor );
+		const promise  = panel.init();
+
+		expect( promise ).to.be.instanceof( Promise );
+
+		return promise;
+	} );
+
 	it( 'should add element to editor\'s focus tracker after init', () => {
 		const spy = sinon.spy( editor.ui.focusTracker, 'add' );
 		const panel = new ImageBalloonPanel( editor );
 
 		sinon.assert.notCalled( spy );
-		panel.init();
-		sinon.assert.calledOnce( spy );
-		sinon.assert.calledWithExactly( spy, panel.element );
+
+		return panel.init().then( () => {
+			sinon.assert.calledOnce( spy );
+			sinon.assert.calledWithExactly( spy, panel.element );
+		} );
 	} );
 
 	it( 'should detach panel when focus is removed', () => {