Răsfoiți Sursa

Change tests for SpecialCharactersNavigationView

panr 5 ani în urmă
părinte
comite
a942f66cb0

+ 2 - 0
packages/ckeditor5-special-characters/src/ui/specialcharactersnavigationview.js

@@ -35,6 +35,8 @@ export default class SpecialCharactersNavigationView extends FormHeaderView {
 
 
 		const t = locale.t;
 		const t = locale.t;
 
 
+		this.set( 'class', 'ck-special-characters-navigation' );
+
 		/**
 		/**
 		 * A dropdown that allows selecting a group of special characters to be displayed.
 		 * A dropdown that allows selecting a group of special characters to be displayed.
 		 *
 		 *

+ 38 - 19
packages/ckeditor5-special-characters/tests/ui/specialcharactersnavigationview.js

@@ -4,8 +4,10 @@
  */
  */
 
 
 import SpecialCharactersNavigationView from '../../src/ui/specialcharactersnavigationview';
 import SpecialCharactersNavigationView from '../../src/ui/specialcharactersnavigationview';
-import LabelView from '@ckeditor/ckeditor5-ui/src/label/labelview';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+import FormHeaderView from '@ckeditor/ckeditor5-ui/src/formheader/formheaderview';
+import LabelView from '@ckeditor/ckeditor5-ui/src/label/labelview';
+import DropdownView from '@ckeditor/ckeditor5-ui/src/dropdown/dropdownview';
 
 
 describe( 'SpecialCharactersNavigationView', () => {
 describe( 'SpecialCharactersNavigationView', () => {
 	let view, locale;
 	let view, locale;
@@ -26,20 +28,29 @@ describe( 'SpecialCharactersNavigationView', () => {
 	} );
 	} );
 
 
 	describe( 'constructor()', () => {
 	describe( 'constructor()', () => {
-		it( 'creates #labelView', () => {
-			expect( view.labelView ).to.be.instanceOf( LabelView );
-			expect( view.labelView.text ).to.equal( 'Special characters' );
+		it( 'should be an instance of the FormHeaderView', () => {
+			expect( view ).to.be.instanceOf( FormHeaderView );
+		} );
+
+		it( 'should have "Special characters" label', () => {
+			expect( view.label ).to.equal( 'Special characters' );
 		} );
 		} );
 
 
 		it( 'creates #groupDropdownView', () => {
 		it( 'creates #groupDropdownView', () => {
+			expect( view.groupDropdownView ).to.be.instanceOf( DropdownView );
 		} );
 		} );
 
 
 		it( 'creates #element from template', () => {
 		it( 'creates #element from template', () => {
 			expect( view.element.classList.contains( 'ck' ) ).to.be.true;
 			expect( view.element.classList.contains( 'ck' ) ).to.be.true;
 			expect( view.element.classList.contains( 'ck-special-characters-navigation' ) ).to.be.true;
 			expect( view.element.classList.contains( 'ck-special-characters-navigation' ) ).to.be.true;
 
 
-			expect( view.element.firstChild ).to.equal( view.labelView.element );
-			expect( view.element.lastChild ).to.equal( view.groupDropdownView.element );
+			expect( view.element.firstChild.classList.contains( 'ck-form__header__label' ) ).to.be.true;
+			expect( view.element.lastChild.classList.contains( 'ck-dropdown' ) ).to.be.true;
+		} );
+
+		it( 'should contain following instances as children: LabelView, Dropdown', () => {
+			expect( view.children.first ).to.be.instanceOf( LabelView );
+			expect( view.children.last ).to.be.instanceOf( DropdownView );
 		} );
 		} );
 	} );
 	} );
 
 
@@ -81,19 +92,6 @@ describe( 'SpecialCharactersNavigationView', () => {
 			view.destroy();
 			view.destroy();
 		} );
 		} );
 
 
-		it( 'binds its buttonView#label to #value', () => {
-			expect( groupDropdownView.buttonView.label ).to.equal( 'groupA' );
-
-			groupDropdownView.listView.items.last.children.first.fire( 'execute' );
-			expect( groupDropdownView.buttonView.label ).to.equal( 'groupB' );
-		} );
-
-		it( 'configures the #buttonView', () => {
-			expect( groupDropdownView.buttonView.isOn ).to.be.false;
-			expect( groupDropdownView.buttonView.withText ).to.be.true;
-			expect( groupDropdownView.buttonView.tooltip ).to.equal( 'Character categories' );
-		} );
-
 		it( 'delegates #execute to the naviation view', () => {
 		it( 'delegates #execute to the naviation view', () => {
 			const spy = sinon.spy();
 			const spy = sinon.spy();
 
 
@@ -103,6 +101,27 @@ describe( 'SpecialCharactersNavigationView', () => {
 			sinon.assert.calledOnce( spy );
 			sinon.assert.calledOnce( spy );
 		} );
 		} );
 
 
+		describe( 'buttonView', () => {
+			it( 'binds #label to #value', () => {
+				expect( groupDropdownView.buttonView.label ).to.equal( 'groupA' );
+
+				groupDropdownView.listView.items.last.children.first.fire( 'execute' );
+				expect( groupDropdownView.buttonView.label ).to.equal( 'groupB' );
+			} );
+
+			it( 'should be configured by the #groupDropdownView', () => {
+				expect( groupDropdownView.buttonView.isOn ).to.be.false;
+				expect( groupDropdownView.buttonView.withText ).to.be.true;
+				expect( groupDropdownView.buttonView.tooltip ).to.equal( 'Character categories' );
+			} );
+
+			it( 'should have class "ck-dropdown__button_label-width_auto"', () => {
+				const element = groupDropdownView.buttonView.element;
+
+				expect( element.classList.contains( 'ck-dropdown__button_label-width_auto' ) ).to.be.true;
+			} );
+		} );
+
 		describe( 'character group list items', () => {
 		describe( 'character group list items', () => {
 			it( 'have basic properties', () => {
 			it( 'have basic properties', () => {
 				expect( groupDropdownView.listView.items
 				expect( groupDropdownView.listView.items