Explorar el Código

Move some of the font utils tests to color grid utils tests

panr hace 5 años
padre
commit
bf283513af
Se han modificado 1 ficheros con 121 adiciones y 0 borrados
  1. 121 0
      packages/ckeditor5-ui/tests/colorgrid/utils.js

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

@@ -0,0 +1,121 @@
+/**
+ * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import {
+	normalizeColorOptions,
+} from '@ckeditor/ckeditor5-ui/src/colorgrid/utils';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+
+describe( 'utils', () => {
+	testUtils.createSinonSandbox();
+
+	describe( 'normalizeColorOptions()', () => {
+		it( 'should return normalized config object from string', () => {
+			const normalizedOption = normalizeColorOptions( [ 'black' ] );
+
+			expect( normalizedOption ).to.deep.equal( [
+				{
+					model: 'black',
+					label: 'black',
+					hasBorder: false,
+					view: {
+						name: 'span',
+						styles: {
+							color: 'black'
+						}
+					}
+				}
+			] );
+		} );
+
+		it( 'should return normalized config object from object( color )', () => {
+			const normalizedOption = normalizeColorOptions( [ { color: 'black' } ] );
+
+			expect( normalizedOption ).to.deep.equal( [
+				{
+					model: 'black',
+					label: 'black',
+					hasBorder: false,
+					view: {
+						name: 'span',
+						styles: {
+							color: 'black'
+						}
+					}
+				}
+			] );
+		} );
+
+		it( 'should return normalized config object from object( color, label )', () => {
+			const normalizedOption = normalizeColorOptions( [
+				{
+					color: 'black',
+					label: 'Black'
+				}
+			] );
+
+			expect( normalizedOption ).to.deep.equal( [
+				{
+					model: 'black',
+					label: 'Black',
+					hasBorder: false,
+					view: {
+						name: 'span',
+						styles: {
+							color: 'black'
+						}
+					}
+				}
+			] );
+		} );
+
+		it( 'should return normalized config object from object( color, label, hasBorder )', () => {
+			const normalizedOption = normalizeColorOptions( [
+				{
+					color: 'black',
+					label: 'Black',
+					hasBorder: true
+				}
+			] );
+
+			expect( normalizedOption ).to.deep.equal( [
+				{
+					model: 'black',
+					label: 'Black',
+					hasBorder: true,
+					view: {
+						name: 'span',
+						styles: {
+							color: 'black'
+						}
+					}
+				}
+			] );
+		} );
+
+		it( 'should return normalized config object from object( color, hasBorder )', () => {
+			const normalizedOption = normalizeColorOptions( [
+				{
+					color: 'black',
+					hasBorder: true
+				}
+			] );
+
+			expect( normalizedOption ).to.deep.equal( [
+				{
+					model: 'black',
+					label: 'black',
+					hasBorder: true,
+					view: {
+						name: 'span',
+						styles: {
+							color: 'black'
+						}
+					}
+				}
+			] );
+		} );
+	} );
+} );