瀏覽代碼

Tests: Add scenario for a setting toolbar max-width

panr 6 年之前
父節點
當前提交
e5903c475b
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      packages/ckeditor5-ui/tests/toolbar/balloon/balloontoolbar.js

+ 13 - 0
packages/ckeditor5-ui/tests/toolbar/balloon/balloontoolbar.js

@@ -344,6 +344,19 @@ describe( 'BalloonToolbar', () => {
 			balloonToolbar.show();
 			balloonToolbar.show();
 			sinon.assert.calledOnce( balloonAddSpy );
 			sinon.assert.calledOnce( balloonAddSpy );
 		} );
 		} );
+
+		it( 'should set balloon toolbar max-width to half of the editable width', () => {
+			const spy = sinon.spy( balloonToolbar, '_setToolbarMaxWidth' );
+			testUtils.sinon.stub( editingView.getDomRoot(), 'getBoundingClientRect' ).returns( { width: 100 } );
+
+			setData( model, '<paragraph>b[a]r</paragraph>' );
+
+			balloonToolbar.show();
+
+			sinon.assert.calledOnce( balloonAddSpy );
+			sinon.assert.calledOnce( spy );
+			expect( balloonToolbar.toolbarView.element.style.maxWidth ).to.be.equal( '50px' );
+		} );
 	} );
 	} );
 
 
 	describe( 'hide()', () => {
 	describe( 'hide()', () => {