8
0
Quellcode durchsuchen

Added tests to Formats feature testing bindings.

Szymon Kupś vor 9 Jahren
Ursprung
Commit
8c2b607788
1 geänderte Dateien mit 23 neuen und 1 gelöschten Zeilen
  1. 23 1
      packages/ckeditor5-heading/tests/formats.js

+ 23 - 1
packages/ckeditor5-heading/tests/formats.js

@@ -14,7 +14,7 @@ import testUtils from '/tests/ckeditor5/_utils/utils.js';
 testUtils.createSinonSandbox();
 
 describe( 'Formats', () => {
-	let editor;
+	let editor, controller;
 
 	beforeEach( () => {
 		return ClassicTestEditor.create( document.getElementById( 'editor' ), {
@@ -23,6 +23,7 @@ describe( 'Formats', () => {
 		} )
 		.then( newEditor => {
 			editor = newEditor;
+			controller = editor.ui.featureComponents.create( 'formats' );
 		} );
 	} );
 
@@ -54,4 +55,25 @@ describe( 'Formats', () => {
 		sinon.assert.calledOnce( executeSpy );
 		sinon.assert.calledWithExactly( executeSpy, 'format', 'paragraph' );
 	} );
+
+	describe( 'model to commanad binding', () => {
+		let model, command;
+
+		beforeEach( () => {
+			model = controller.model;
+			command = editor.commands.get( 'format' );
+		} );
+
+		it( 'isEnabled', () => {
+			expect( model.isEnabled ).to.be.true;
+			command.isEnabled = false;
+			expect( model.isEnabled ).to.be.false;
+		} );
+
+		it( 'label', () => {
+			expect( model.label ).to.equal( 'Paragraph' );
+			command.format = command.formats[ 1 ];
+			expect( model.label ).to.equal( 'Heading 1' );
+		} );
+	} );
 } );