Browse Source

Tests: Added tests for ToolbarView#isCompact.

Aleksander Nowodzinski 5 years ago
parent
commit
3146ed1c20

+ 9 - 0
packages/ckeditor5-ui/src/toolbar/toolbarview.js

@@ -114,6 +114,15 @@ export default class ToolbarView extends View {
 		this.set( 'class' );
 
 		/**
+		 * When set true, makes the toolbar look compact with {@link #element}.
+		 *
+		 * @observable
+		 * @default false
+		 * @member {String} #isCompact
+		 */
+		this.set( 'isCompact', false );
+
+		/**
 		 * A (child) view containing {@link #items toolbar items}.
 		 *
 		 * @readonly

+ 12 - 0
packages/ckeditor5-ui/tests/toolbar/toolbarview.js

@@ -54,6 +54,10 @@ describe( 'ToolbarView', () => {
 			expect( view.locale ).to.equal( locale );
 		} );
 
+		it( 'should set view#isCompact', () => {
+			expect( view.isCompact ).to.be.false;
+		} );
+
 		describe( '#options', () => {
 			it( 'should be an empty object if none were passed', () => {
 				expect( view.options ).to.deep.equal( {} );
@@ -166,6 +170,14 @@ describe( 'ToolbarView', () => {
 				expect( view.element.classList.contains( 'foo' ) ).to.be.false;
 				expect( view.element.classList.contains( 'bar' ) ).to.be.false;
 			} );
+
+			it( 'reacts on view#isCompact', () => {
+				view.isCompact = false;
+				expect( view.element.classList.contains( 'ck-toolbar_compact' ) ).to.be.false;
+
+				view.isCompact = true;
+				expect( view.element.classList.contains( 'ck-toolbar_compact' ) ).to.be.true;
+			} );
 		} );
 
 		describe( 'style', () => {