Browse Source

Add unit test for renderDowncastElement function.

Mateusz Samsel 6 năm trước cách đây
mục cha
commit
1bed91007c
1 tập tin đã thay đổi với 16 bổ sung3 xóa
  1. 16 3
      packages/ckeditor5-font/tests/utils.js

+ 16 - 3
packages/ckeditor5-font/tests/utils.js

@@ -7,19 +7,23 @@ import {
 	FONT_COLOR,
 	FONT_BACKGROUND_COLOR,
 	normalizeColorOptions,
-	addColorTableToDropdown
+	addColorTableToDropdown,
+	renderDowncastElement
 } from './../src/utils';
 import { createDropdown } from '@ckeditor/ckeditor5-ui/src/dropdown/utils';
 import ColorTableView from './../src/ui/colortableview';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
 describe( 'utils', () => {
+	testUtils.createSinonSandbox();
+
 	describe( 'color and background color related', () => {
 		it( 'plugin names has proper values', () => {
 			expect( FONT_COLOR ).to.equal( 'fontColor' );
 			expect( FONT_BACKGROUND_COLOR ).to.equal( 'fontBackgroundColor' );
 		} );
 
-		it( 'normalizeColorOptions can produce the same output object', () => {
+		it( 'normalizeColorOptions() can produce the same output object', () => {
 			const normalizedArray = normalizeColorOptions( [
 				'black',
 				{
@@ -99,7 +103,7 @@ describe( 'utils', () => {
 			] );
 		} );
 
-		it( 'adding colors table to dropdown works', () => {
+		it( 'addColorTableToDropdown()', () => {
 			const dropdown = createDropdown();
 			dropdown.render();
 
@@ -128,5 +132,14 @@ describe( 'utils', () => {
 			expect( dropdown.colorTableView ).to.be.instanceOf( ColorTableView );
 			expect( dropdown.panelView.children.length ).to.equal( 1 );
 		} );
+
+		it( 'renderDowncastElement()', () => {
+			const testRender = renderDowncastElement( 'color' );
+			const fake = testUtils.sinon.fake();
+
+			testRender( 'blue', { createAttributeElement: fake } );
+
+			sinon.assert.calledWithExactly( fake, 'span', { style: 'color:blue' }, { priority: 7 } );
+		} );
 	} );
 } );