8
0
Просмотр исходного кода

Fix incorrect tooltip text when option's value is set to `null`.

panr 5 лет назад
Родитель
Сommit
15eb996636

+ 1 - 1
packages/ckeditor5-image/src/imageresize/ui/imageresizeui.js

@@ -80,7 +80,7 @@ export default class ImageResizeUI extends Plugin {
 			button.set( {
 				label: t( label ),
 				withText: true,
-				tooltip: t( 'Resize image to' ) + ' ' + parsedValue,
+				tooltip: t( 'Resize image to' ) + ' ' + ( parsedValue || 'the original size' ),
 				isToggleable: true,
 				commandValue: parsedValue
 			} );

+ 11 - 0
packages/ckeditor5-image/tests/imageresize/ui/imageresizeui.js

@@ -216,6 +216,17 @@ describe( 'ImageResizeUI', () => {
 			expect( buttonView.labelView ).to.be.instanceOf( View );
 		} );
 
+		it( 'should be created with a proper tooltip, depends on the set value', () => {
+			const buttonViewOriginal = editor.ui.componentFactory.create( 'imageResize:original' );
+			const buttonView50 = editor.ui.componentFactory.create( 'imageResize:50' );
+
+			buttonViewOriginal.render();
+			buttonView50.render();
+
+			expect( buttonViewOriginal.tooltip ).to.equal( 'Resize image to the original size' );
+			expect( buttonView50.tooltip ).to.equal( 'Resize image to 50%' );
+		} );
+
 		it( 'should have `commandValue` equal "50%"', () => {
 			const buttonView = editor.ui.componentFactory.create( 'imageResize:50' );