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

Add reference to color table in dropdown, fix unit test.

Mateusz Samsel 6 лет назад
Родитель
Сommit
3ae45b555e

+ 1 - 1
packages/ckeditor5-font/src/utils.js

@@ -83,7 +83,7 @@ export const colorUI = {
 	addColorsToDropdown( dropdownView, colors ) {
 		const locale = dropdownView.locale;
 		const colorTableView = new ColorTableView( locale, { colors } );
-
+		dropdownView.colorTableView = colorTableView;
 		dropdownView.panelView.children.add( colorTableView );
 
 		colorTableView.delegate( 'execute' ).to( dropdownView, 'execute' );

+ 17 - 3
packages/ckeditor5-font/tests/fontcolor/fontcolorediting.js

@@ -171,10 +171,24 @@ describe( 'FontColorEditing', () => {
 			} )
 		);
 
-		it( 'should convert fontColor attribute to proper style value.', () => {
-			setModelData( doc, '<paragraph>fo<$text fontColor="#000">o b</$text>ar</paragraph>' );
+		describe( 'convert different color version', () => {
+			const tests = [
+				'#000',
+				'green',
+				'rgb( 0, 10, 20 )',
+				'rgba( 20, 30, 50, 0.4)',
+				'hsl( 10, 20%, 30%)',
+				'hsla( 300, 50%, 100%, .3)',
+				'rgb( 20%, 30%, 40% )',
+				'#345678'
+			];
+			tests.forEach( test => {
+				it( `should convert fontColor attribute: "${ test }" to proper style value.`, () => {
+					setModelData( doc, `<paragraph>fo<$text fontColor="${ test }">o b</$text>ar</paragraph>` );
 
-			expect( editor.getData() ).to.equal( '<p>fo<span style="color:#000;">o b</span>ar</p>' );
+					expect( editor.getData() ).to.equal( `<p>fo<span style="color:${ test };">o b</span>ar</p>` );
+				} );
+			} );
 		} );
 	} );
 } );

+ 12 - 6
packages/ckeditor5-font/tests/fontcolor/fontcolorui.js

@@ -78,7 +78,7 @@ describe( 'FontColorUI', () => {
 			expect( dropdown.element.classList.contains( 'ck-font-color-dropdown' ) ).to.be.true;
 		} );
 
-		it( 'should focus view after command execution', () => {
+		it( 'should focus view after command execution from dropdown', () => {
 			const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
 			const dropdown = editor.ui.componentFactory.create( 'fontColor' );
 
@@ -88,6 +88,16 @@ describe( 'FontColorUI', () => {
 			sinon.assert.calledOnce( focusSpy );
 		} );
 
+		it( 'should focus view after command execution from splitbutton', () => {
+			const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
+			const dropdown = editor.ui.componentFactory.create( 'fontColor' );
+
+			dropdown.commandName = 'fontColor';
+			dropdown.buttonView.fire( 'execute' );
+
+			sinon.assert.calledOnce( focusSpy );
+		} );
+
 		describe( 'model to command binding', () => {
 			it( 'isEnabled', () => {
 				command.isEnabled = false;
@@ -112,11 +122,7 @@ describe( 'FontColorUI', () => {
 
 			it( 'works for the colorTableView#items in the panel', () => {
 				const colorTableView = dropdown.colorTableView;
-
-				expect( colorTableView.items.map( item => item.children.first.label ) ).to.deep.equal( [
-					'Domyślna',
-					'Arial'
-				] );
+				expect( colorTableView.removeButtonTooltip ).to.equal( 'Usuń kolor tekstu' );
 			} );
 
 			function localizedEditor() {