Browse Source

Tests: Added tests for the getLocalizedColorOptions() helper.

Aleksander Nowodzinski 5 years ago
parent
commit
5177933c70
1 changed files with 51 additions and 0 deletions
  1. 51 0
      packages/ckeditor5-ui/tests/colorgrid/utils.js

+ 51 - 0
packages/ckeditor5-ui/tests/colorgrid/utils.js

@@ -5,6 +5,7 @@
 
 import {
 	normalizeColorOptions,
+	getLocalizedColorOptions
 } from '@ckeditor/ckeditor5-ui/src/colorgrid/utils';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
@@ -118,4 +119,54 @@ describe( 'utils', () => {
 			] );
 		} );
 	} );
+
+	describe( 'getLocalizedColorOptions()', () => {
+		const locale = {
+			t: string => 'Localized:' + string
+		};
+
+		it( 'should return localized color options', () => {
+			expect( getLocalizedColorOptions( locale, [
+				{
+					color: 'red',
+					label: 'Red'
+				},
+				{
+					color: 'blue',
+					label: 'Blue'
+				}
+			] ) ).to.deep.equal( [
+				{
+					color: 'red',
+					label: 'Localized:Red'
+				},
+				{
+					color: 'blue',
+					label: 'Localized:Blue'
+				}
+			] );
+		} );
+
+		it( 'should omit unknown color options', () => {
+			expect( getLocalizedColorOptions( locale, [
+				{
+					color: 'red',
+					label: 'Red'
+				},
+				{
+					color: 'unknown',
+					label: 'Unknown'
+				}
+			] ) ).to.deep.equal( [
+				{
+					color: 'red',
+					label: 'Localized:Red'
+				},
+				{
+					color: 'unknown',
+					label: 'Unknown'
+				}
+			] );
+		} );
+	} );
 } );