Преглед на файлове

MVC refactoring followups.

Aleksander Nowodzinski преди 9 години
родител
ревизия
14597b9620
променени са 2 файла, в които са добавени 38 реда и са изтрити 35 реда
  1. 0 2
      packages/ckeditor5-heading/src/heading.js
  2. 38 33
      packages/ckeditor5-heading/tests/heading.js

+ 0 - 2
packages/ckeditor5-heading/src/heading.js

@@ -46,8 +46,6 @@ export default class Heading extends Feature {
 
 		// Create dropdown model.
 		const dropdownModel = new Model( {
-			isEnabled: true,
-			isOn: false,
 			label: 'Heading',
 			withText: true,
 			items: collection

+ 38 - 33
packages/ckeditor5-heading/tests/heading.js

@@ -38,53 +38,58 @@ describe( 'Heading', () => {
 		expect( editor.plugins.get( Heading ) ).to.be.instanceOf( Heading );
 	} );
 
-	it( 'should load FormatsEngine', () => {
+	it( 'should load HeadingEngine', () => {
 		expect( editor.plugins.get( HeadingEngine ) ).to.be.instanceOf( HeadingEngine );
 	} );
 
-	it( 'should register formats feature component', () => {
-		const dropdown = editor.ui.featureComponents.create( 'headings' );
+	describe( 'init()', () => {
+		it( 'should register formats feature component', () => {
+			const dropdown = editor.ui.featureComponents.create( 'headings' );
 
-		expect( dropdown ).to.be.instanceOf( DropdownView );
-	} );
+			expect( dropdown ).to.be.instanceOf( DropdownView );
+			expect( dropdown.buttonView.isEnabled ).to.be.true;
+			expect( dropdown.buttonView.isOn ).to.be.undefined;
+			expect( dropdown.buttonView.label ).to.equal( 'Paragraph' );
+		} );
 
-	it( 'should execute format command on model execute event', () => {
-		const executeSpy = testUtils.sinon.spy( editor, 'execute' );
-		const dropdown = editor.ui.featureComponents.create( 'headings' );
+		it( 'should execute format command on model execute event', () => {
+			const executeSpy = testUtils.sinon.spy( editor, 'execute' );
+			const dropdown = editor.ui.featureComponents.create( 'headings' );
 
-		dropdown.formatId = 'foo';
-		dropdown.fire( 'execute' );
+			dropdown.formatId = 'foo';
+			dropdown.fire( 'execute' );
 
-		sinon.assert.calledOnce( executeSpy );
-		sinon.assert.calledWithExactly( executeSpy, 'heading', { formatId: 'foo' } );
-	} );
+			sinon.assert.calledOnce( executeSpy );
+			sinon.assert.calledWithExactly( executeSpy, 'heading', { formatId: 'foo' } );
+		} );
 
-	it( 'should focus view after command execution', () => {
-		const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
-		const dropdown = editor.ui.featureComponents.create( 'headings' );
+		it( 'should focus view after command execution', () => {
+			const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
+			const dropdown = editor.ui.featureComponents.create( 'headings' );
 
-		dropdown.fire( 'execute' );
+			dropdown.fire( 'execute' );
 
-		sinon.assert.calledOnce( focusSpy );
-	} );
+			sinon.assert.calledOnce( focusSpy );
+		} );
 
-	describe( 'model to command binding', () => {
-		let command;
+		describe( 'model to command binding', () => {
+			let command;
 
-		beforeEach( () => {
-			command = editor.commands.get( 'heading' );
-		} );
+			beforeEach( () => {
+				command = editor.commands.get( 'heading' );
+			} );
 
-		it( 'isEnabled', () => {
-			expect( dropdown.buttonView.isEnabled ).to.be.true;
-			command.isEnabled = false;
-			expect( dropdown.buttonView.isEnabled ).to.be.false;
-		} );
+			it( 'isEnabled', () => {
+				expect( dropdown.buttonView.isEnabled ).to.be.true;
+				command.isEnabled = false;
+				expect( dropdown.buttonView.isEnabled ).to.be.false;
+			} );
 
-		it( 'label', () => {
-			expect( dropdown.buttonView.label ).to.equal( 'Paragraph' );
-			command.value = command.formats[ 1 ];
-			expect( dropdown.buttonView.label ).to.equal( 'Heading 1' );
+			it( 'label', () => {
+				expect( dropdown.buttonView.label ).to.equal( 'Paragraph' );
+				command.value = command.formats[ 1 ];
+				expect( dropdown.buttonView.label ).to.equal( 'Heading 1' );
+			} );
 		} );
 	} );
 } );