8
0
Просмотр исходного кода

Move Indent* tests to indent also.

Maciej Gołaszewski 6 лет назад
Родитель
Сommit
a29a7a2eea

+ 1 - 1
packages/ckeditor5-indent/src/indent.js

@@ -7,7 +7,7 @@
  * @module indent/indent
  */
 
-import Plugin from '../plugin';
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
 import IndentEditing from './indentediting';
 import IndentUI from './indentui';

+ 2 - 2
packages/ckeditor5-indent/src/indentediting.js

@@ -7,8 +7,8 @@
  * @module indent/indentediting
  */
 
-import Plugin from '../plugin';
-import MultiCommand from '../multicommand';
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import MultiCommand from '@ckeditor/ckeditor5-core/src/multicommand';
 
 /**
  * The indent editing feature.

+ 1 - 1
packages/ckeditor5-indent/src/indentui.js

@@ -7,8 +7,8 @@
  * @module indent/indentui
  */
 import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
-import Plugin from '../plugin';
 
 /**
  * The indent feature.

+ 50 - 0
packages/ckeditor5-indent/tests/indent.js

@@ -0,0 +1,50 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/* global document */
+
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+
+import Indent from '../src/indent';
+import IndentEditing from '../src/indentediting';
+import IndentUI from '../src/indentui';
+
+describe( 'Indent', () => {
+	let editor, element;
+
+	testUtils.createSinonSandbox();
+
+	beforeEach( () => {
+		element = document.createElement( 'div' );
+		document.body.appendChild( element );
+
+		return ClassicTestEditor
+			.create( element, { plugins: [ Indent ] } )
+			.then( newEditor => {
+				editor = newEditor;
+			} );
+	} );
+
+	afterEach( () => {
+		element.remove();
+
+		if ( editor ) {
+			return editor.destroy();
+		}
+	} );
+
+	it( 'should be named', () => {
+		expect( Indent.pluginName ).to.equal( 'Indent' );
+	} );
+
+	it( 'should load the IndentUI plugin', () => {
+		expect( editor.plugins.get( IndentUI ) ).to.be.instanceOf( IndentUI );
+	} );
+
+	it( 'should load the IndentEditing plugin', () => {
+		expect( editor.plugins.get( IndentEditing ) ).to.be.instanceOf( IndentEditing );
+	} );
+} );

+ 1 - 1
packages/ckeditor5-indent/tests/indentblock-integration.js

@@ -7,9 +7,9 @@ import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtest
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
-import IndentEditing from '@ckeditor/ckeditor5-core/src/indent/indentediting';
 import HeadingEditing from '@ckeditor/ckeditor5-heading/src/headingediting';
 
+import IndentEditing from '../src/indentediting';
 import IndentBlock from '../src/indentblock';
 
 describe( 'IndentBlock - integration', () => {

+ 1 - 1
packages/ckeditor5-indent/tests/indentblock.js

@@ -8,9 +8,9 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import HeadingEditing from '@ckeditor/ckeditor5-heading/src/headingediting';
-import IndentEditing from '@ckeditor/ckeditor5-core/src/indent/indentediting';
 import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
 
+import IndentEditing from '../src/indentediting';
 import IndentBlock from '../src/indentblock';
 import IndentBlockCommand from '../src/indentblockcommand';
 

+ 50 - 0
packages/ckeditor5-indent/tests/indentediting.js

@@ -0,0 +1,50 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+import MultiCommand from '@ckeditor/ckeditor5-core/src/multicommand';
+
+import IndentEditing from '../src/indentediting';
+
+describe( 'IndentEditing', () => {
+	let editor;
+
+	testUtils.createSinonSandbox();
+
+	beforeEach( () => {
+		return VirtualTestEditor
+			.create( { plugins: [ IndentEditing ] } )
+			.then( newEditor => {
+				editor = newEditor;
+			} );
+	} );
+
+	afterEach( () => {
+		if ( editor ) {
+			return editor.destroy();
+		}
+	} );
+
+	it( 'should be named', () => {
+		expect( IndentEditing.pluginName ).to.equal( 'IndentEditing' );
+	} );
+
+	it( 'should be loaded', () => {
+		expect( editor.plugins.get( IndentEditing ) ).to.be.instanceOf( IndentEditing );
+	} );
+
+	it( 'should register indent command', () => {
+		const command = editor.commands.get( 'indent' );
+
+		expect( command ).to.be.instanceof( MultiCommand );
+	} );
+
+	it( 'should register outdent command', () => {
+		const command = editor.commands.get( 'outdent' );
+
+		expect( command ).to.be.instanceof( MultiCommand );
+	} );
+} );

+ 78 - 0
packages/ckeditor5-indent/tests/indentui.js

@@ -0,0 +1,78 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/* global document */
+
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
+
+import IndentEditing from '../src/indentediting';
+import IndentUI from '../src/indentui';
+
+describe( 'IndentUI', () => {
+	let editor, element;
+
+	testUtils.createSinonSandbox();
+
+	beforeEach( () => {
+		element = document.createElement( 'div' );
+		document.body.appendChild( element );
+
+		return ClassicTestEditor
+			.create( element, { plugins: [ IndentUI, IndentEditing ] } )
+			.then( newEditor => {
+				editor = newEditor;
+			} );
+	} );
+
+	afterEach( () => {
+		element.remove();
+
+		if ( editor ) {
+			return editor.destroy();
+		}
+	} );
+
+	it( 'should be named', () => {
+		expect( IndentUI.pluginName ).to.equal( 'IndentUI' );
+	} );
+
+	it( 'should be loaded', () => {
+		expect( editor.plugins.get( IndentUI ) ).to.be.instanceOf( IndentUI );
+	} );
+
+	it( 'should set up button for indent', () => {
+		const indentButton = editor.ui.componentFactory.create( 'indent' );
+
+		expect( indentButton ).to.be.instanceOf( ButtonView );
+	} );
+
+	it( 'should set up button for indent', () => {
+		const outdentButton = editor.ui.componentFactory.create( 'outdent' );
+
+		expect( outdentButton ).to.be.instanceOf( ButtonView );
+	} );
+
+	it( 'should execute indent command on button execute', () => {
+		const button = editor.ui.componentFactory.create( 'indent' );
+		const spy = sinon.spy( editor, 'execute' );
+
+		button.fire( 'execute' );
+
+		sinon.assert.calledOnce( spy );
+		sinon.assert.calledWithExactly( spy, 'indent' );
+	} );
+
+	it( 'should execute outdent command on button execute', () => {
+		const button = editor.ui.componentFactory.create( 'outdent' );
+		const spy = sinon.spy( editor, 'execute' );
+
+		button.fire( 'execute' );
+
+		sinon.assert.calledOnce( spy );
+		sinon.assert.calledWithExactly( spy, 'outdent' );
+	} );
+} );