Преглед изворни кода

Add unit test for color translations.

Mateusz Samsel пре 6 година
родитељ
комит
59449fccd3

+ 44 - 15
packages/ckeditor5-font/tests/fontcolor/fontcolorediting.js

@@ -39,24 +39,53 @@ describe( 'FontColorEditing', () => {
 		describe( 'default value', () => {
 		describe( 'default value', () => {
 			it( 'should be set', () => {
 			it( 'should be set', () => {
 				expect( editor.config.get( 'fontColor.colors' ) ).to.deep.equal( [
 				expect( editor.config.get( 'fontColor.colors' ) ).to.deep.equal( [
-					'hsl(0, 0%, 0%)',
-					'hsl(0, 0%, 30%)',
-					'hsl(0, 0%, 60%)',
-					'hsl(0, 0%, 90%)',
 					{
 					{
+						color: 'hsl(0, 0%, 0%)',
+						label: 'Black'
+					}, {
+						color: 'hsl(0, 0%, 30%)',
+						label: 'Dim grey'
+					}, {
+						color: 'hsl(0, 0%, 60%)',
+						label: 'Grey'
+					}, {
+						color: 'hsl(0, 0%, 90%)',
+						label: 'Light grey'
+					}, {
 						color: 'hsl(0, 0%, 100%)',
 						color: 'hsl(0, 0%, 100%)',
+						label: 'White',
 						hasBorder: true
 						hasBorder: true
-					},
-					'hsl(360, 75%, 60%)',
-					'hsl(30, 75%, 60%)',
-					'hsl(60, 75%, 60%)',
-					'hsl(90, 75%, 60%)',
-					'hsl(120, 75%, 60%)',
-					'hsl(150, 75%, 60%)',
-					'hsl(180, 75%, 60%)',
-					'hsl(210, 75%, 60%)',
-					'hsl(240, 75%, 60%)',
-					'hsl(270, 75%, 60%)'
+					}, {
+						color: 'hsl(0, 75%, 60%)',
+						label: 'Red'
+					}, {
+						color: 'hsl(30, 75%, 60%)',
+						label: 'Orange'
+					}, {
+						color: 'hsl(60, 75%, 60%)',
+						label: 'Yellow'
+					}, {
+						color: 'hsl(90, 75%, 60%)',
+						label: 'Light green'
+					}, {
+						color: 'hsl(120, 75%, 60%)',
+						label: 'Green'
+					}, {
+						color: 'hsl(150, 75%, 60%)',
+						label: 'Aquamarine'
+					}, {
+						color: 'hsl(180, 75%, 60%)',
+						label: 'Turquoise'
+					}, {
+						color: 'hsl(210, 75%, 60%)',
+						label: 'Light blue'
+					}, {
+						color: 'hsl(240, 75%, 60%)',
+						label: 'Blue'
+					}, {
+						color: 'hsl(270, 75%, 60%)',
+						label: 'Purple'
+					}
 				] );
 				] );
 			} );
 			} );
 		} );
 		} );

+ 49 - 2
packages/ckeditor5-font/tests/fontcolor/fontcolorui.js

@@ -22,12 +22,25 @@ describe( 'FontColorUI', () => {
 	before( () => {
 	before( () => {
 		addTranslations( 'en', {
 		addTranslations( 'en', {
 			'Font Color': 'Font Color',
 			'Font Color': 'Font Color',
-			'Remove color': 'Remove text color'
+			'Remove color': 'Remove text color',
+			'Black': 'Black',
+			'White': 'White',
+			'Red': 'Red',
+			'Orange': 'Orange',
+			'Blue': 'Blue',
+			'Green': 'Green'
 		} );
 		} );
 
 
 		addTranslations( 'pl', {
 		addTranslations( 'pl', {
 			'Font Color': 'Kolor czcionki',
 			'Font Color': 'Kolor czcionki',
-			'Remove color': 'Usuń kolor'
+			'Remove color': 'Usuń kolor',
+			'Black': 'Czarny',
+			'White': 'Biały',
+			'Red': 'Czerwony',
+			'Orange': 'Pomarańczowy',
+			'Blue': 'Niebieski',
+			'Green': 'Zielony',
+			'Yellow': 'Żółty'
 		} );
 		} );
 	} );
 	} );
 
 
@@ -116,6 +129,40 @@ describe( 'FontColorUI', () => {
 				expect( colorTableView.items.first.label ).to.equal( 'Usuń kolor' );
 				expect( colorTableView.items.first.label ).to.equal( 'Usuń kolor' );
 			} );
 			} );
 
 
+			describe( 'works for', () => {
+				const colors = [
+					{
+						color: 'hsl(0, 0%, 0%)',
+						label: 'Czarny'
+					}, {
+						color: 'hsl(0, 0%, 100%)',
+						label: 'Biały'
+					}, {
+						color: 'hsl(0, 75%, 60%)',
+						label: 'Czerwony'
+					}, {
+						color: 'hsl(30, 75%, 60%)',
+						label: 'Pomarańczowy'
+					}, {
+						color: 'hsl(240, 75%, 60%)',
+						label: 'Niebieski'
+					}, {
+						color: 'hsl(120, 75%, 60%)',
+						label: 'Zielony'
+					}, {
+						color: 'hsl(60, 75%, 60%)',
+						label: 'Żółty'
+					}
+				];
+
+				colors.forEach( test => {
+					it( `tested color ${ test.color } with name ${ test.label }.`, () => {
+						const colorGrid = dropdown.colorTableView.items.get( 1 );
+						const tile = colorGrid.items.find( colorTile => test.color === colorTile.color );
+						expect( tile.label ).to.equal( test.label );
+					} );
+				} );
+			} );
 			function localizedEditor() {
 			function localizedEditor() {
 				const editorElement = document.createElement( 'div' );
 				const editorElement = document.createElement( 'div' );
 				document.body.appendChild( editorElement );
 				document.body.appendChild( editorElement );