Browse Source

Tests: Added CodeBlockCommand tests to check if the "language" option is supported when executing.

Aleksander Nowodzinski 6 years ago
parent
commit
8147b9f4ea
1 changed files with 17 additions and 1 deletions
  1. 17 1
      packages/ckeditor5-code-block/tests/codeblockcommand.js

+ 17 - 1
packages/ckeditor5-code-block/tests/codeblockcommand.js

@@ -14,7 +14,7 @@ import BlockQuoteEditing from '@ckeditor/ckeditor5-block-quote/src/blockquoteedi
 import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
-describe.only( 'CodeBlockCommand', () => {
+describe( 'CodeBlockCommand', () => {
 	let editor, model, command;
 
 	beforeEach( () => {
@@ -232,6 +232,22 @@ describe.only( 'CodeBlockCommand', () => {
 
 			expect( getModelData( model ) ).to.equal( '<codeBlock language="plaintext">f[o]o</codeBlock>' );
 		} );
+
+		it( 'should allow setting the language of the new block', () => {
+			setModelData( model, '<paragraph>f[o]o</paragraph>' );
+
+			command.execute( { language: 'css' } );
+
+			expect( getModelData( model ) ).to.equal( '<codeBlock language="css">f[o]o</codeBlock>' );
+		} );
+
+		it( 'should allow changing the language of the existing block', () => {
+			setModelData( model, '<codeBlock language="plaintext">f[o]o</codeBlock>' );
+
+			command.execute( { language: 'css', forceValue: true } );
+
+			expect( getModelData( model ) ).to.equal( '<codeBlock language="css">f[o]o</codeBlock>' );
+		} );
 	} );
 
 	describe( 'BlockQuote integration', () => {