浏览代码

Merge pull request #72 from ckeditor/t/71

Moved component tests to ckeditor5-ui-default.
Aleksander Nowodzinski 9 年之前
父节点
当前提交
cbc0b9f4f1

+ 0 - 52
packages/ckeditor5-ui/tests/bindings/stickytoolbar.js

@@ -1,52 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: ui, bindings, toolbar */
-
-import Editor from '/ckeditor5/core/editor/editor.js';
-import Model from '/ckeditor5/ui/model.js';
-import View from '/ckeditor5/ui/view.js';
-import Controller from '/ckeditor5/ui/controller.js';
-import StickyToolbar from '/ckeditor5/ui/bindings/stickytoolbar.js';
-
-import testUtils from '/tests/core/_utils/utils.js';
-testUtils.createSinonSandbox();
-
-describe( 'StickyToolbar', () => {
-	let toolbar, model;
-
-	const editor = new Editor();
-
-	editor.ui = {
-		featureComponents: {
-			create: () => new Controller()
-		}
-	};
-
-	beforeEach( () => {
-		model = new Model( {
-			isActive: false,
-			config: [ 'bold', 'italic' ]
-		} );
-
-		toolbar = new StickyToolbar( model, new View(), editor );
-	} );
-
-	describe( 'constructor', () => {
-		it( 'sets all the properties', () => {
-			expect( toolbar ).to.have.property( 'editor', editor );
-		} );
-	} );
-
-	describe( 'init', () => {
-		it( 'calls bindToolbarItems', () => {
-			const spy = testUtils.sinon.spy( toolbar, 'bindToolbarItems' );
-
-			return toolbar.init().then( () => {
-				expect( spy.calledOnce ).to.be.true;
-			} );
-		} );
-	} );
-} );

+ 0 - 52
packages/ckeditor5-ui/tests/bindings/toolbar.js

@@ -1,52 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: ui, bindings, toolbar */
-
-import Editor from '/ckeditor5/core/editor/editor.js';
-import Model from '/ckeditor5/ui/model.js';
-import View from '/ckeditor5/ui/view.js';
-import Controller from '/ckeditor5/ui/controller.js';
-import Toolbar from '/ckeditor5/ui/bindings/toolbar.js';
-
-import testUtils from '/tests/core/_utils/utils.js';
-testUtils.createSinonSandbox();
-
-describe( 'Toolbar', () => {
-	let toolbar, model;
-
-	const editor = new Editor();
-
-	editor.ui = {
-		featureComponents: {
-			create: () => new Controller()
-		}
-	};
-
-	beforeEach( () => {
-		model = new Model( {
-			isActive: false,
-			config: [ 'bold', 'italic' ]
-		} );
-
-		toolbar = new Toolbar( model, new View(), editor );
-	} );
-
-	describe( 'constructor', () => {
-		it( 'sets all the properties', () => {
-			expect( toolbar ).to.have.property( 'editor', editor );
-		} );
-	} );
-
-	describe( 'init', () => {
-		it( 'calls bindToolbarItems', () => {
-			const spy = testUtils.sinon.spy( toolbar, 'bindToolbarItems' );
-
-			return toolbar.init().then( () => {
-				expect( spy.calledOnce ).to.be.true;
-			} );
-		} );
-	} );
-} );

+ 0 - 68
packages/ckeditor5-ui/tests/bindings/toolbarbindingsmixin.js

@@ -1,68 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: ui, bindings, toolbar */
-
-import mix from '/ckeditor5/utils/mix.js';
-import Editor from '/ckeditor5/core/editor/editor.js';
-import Collection from '/ckeditor5/utils/collection.js';
-import Model from '/ckeditor5/ui/model.js';
-import Controller from '/ckeditor5/ui/controller.js';
-import ToolbarBindingsMixin from '/ckeditor5/ui/bindings/toolbarbindingsmixin.js';
-
-describe( 'ToolbarBindingsMixin', () => {
-	const editor = new Editor();
-	let mixinInstance;
-
-	editor.ui = {
-		featureComponents: {
-			create: () => new Controller()
-		}
-	};
-
-	class MixClass extends Controller {
-		constructor( model, view ) {
-			super( model, view );
-
-			this.editor = editor;
-			this.addCollection( 'items' );
-		}
-	}
-
-	mix( MixClass, ToolbarBindingsMixin );
-
-	beforeEach( () => {
-		mixinInstance = new MixClass( new Model( {
-			config: [ 'bold', 'italic' ]
-		} ) );
-	} );
-
-	describe( 'bindToolbarItems', () => {
-		it( 'creates item collection', () => {
-			mixinInstance.bindToolbarItems();
-
-			expect( mixinInstance.items ).to.be.instanceOf( Collection );
-			expect( mixinInstance.items.map( i => i.name ) ).to.have.members( [ 'bold', 'italic' ] );
-		} );
-
-		it( 'works when no config specified in the model', () => {
-			mixinInstance = new MixClass( new Model( {} ) );
-			mixinInstance.bindToolbarItems();
-
-			expect( mixinInstance.items ).to.be.instanceOf( Collection );
-			expect( mixinInstance.items ).to.have.length( 0 );
-		} );
-
-		it( 'binds item collection to "items" controller collection', () => {
-			const items = mixinInstance.collections.get( 'items' );
-
-			expect( items ).to.have.length( 0 );
-
-			mixinInstance.bindToolbarItems();
-
-			expect( items ).to.have.length( 2 );
-		} );
-	} );
-} );

+ 0 - 34
packages/ckeditor5-ui/tests/boxededitorui/boxededitorui.js

@@ -1,34 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-import Editor from '/ckeditor5/core/editor/editor.js';
-import BoxedEditorUI from '/ckeditor5/ui/editorui/boxed/boxededitorui.js';
-import ControllerCollection from '/ckeditor5/ui/controllercollection.js';
-
-describe( 'BoxedEditorUI', () => {
-	let editor, boxedEditorUI;
-
-	beforeEach( () => {
-		editor = new Editor( null, {
-			ui: {
-				width: 100,
-				height: 200
-			}
-		} );
-		boxedEditorUI = new BoxedEditorUI( editor );
-	} );
-
-	describe( 'constructor', () => {
-		it( 'adds controller collections', () => {
-			expect( boxedEditorUI.collections.get( 'top' ) ).to.be.instanceof( ControllerCollection );
-			expect( boxedEditorUI.collections.get( 'main' ) ).to.be.instanceof( ControllerCollection );
-		} );
-
-		it( 'sets "width" and "height" attributes', () => {
-			expect( boxedEditorUI.width ).to.equal( editor.config.get( 'ui.width' ) );
-			expect( boxedEditorUI.height ).to.equal( editor.config.get( 'ui.height' ) );
-		} );
-	} );
-} );

+ 0 - 50
packages/ckeditor5-ui/tests/boxededitorui/boxededitoruiview.js

@@ -1,50 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-import BoxedEditorUIView from '/ckeditor5/ui/editorui/boxed/boxededitoruiview.js';
-import Locale from '/ckeditor5/utils/locale.js';
-
-describe( 'BoxedEditorUIView', () => {
-	let boxedEditorUIView, element, topRegionEl, mainRegionEl;
-
-	beforeEach( () => {
-		boxedEditorUIView = new BoxedEditorUIView( new Locale( 'en' ) );
-		boxedEditorUIView.init();
-
-		element = boxedEditorUIView.element;
-
-		const regions = boxedEditorUIView.regions;
-		topRegionEl = regions.get( 'top' ).element;
-		mainRegionEl = regions.get( 'main' ).element;
-	} );
-
-	describe( 'constructor', () => {
-		it( 'creates the regions', () => {
-			expect( topRegionEl.parentNode ).to.equal( boxedEditorUIView.element );
-			expect( mainRegionEl.parentNode ).to.equal( boxedEditorUIView.element );
-		} );
-
-		it( 'bootstraps the view element from template', () => {
-			expect( boxedEditorUIView.element.classList.contains( 'ck-editor' ) ).to.be.true;
-		} );
-
-		it( 'setups accessibility of the view element', () => {
-			expect( element.attributes.getNamedItem( 'aria-labelledby' ).value ).to.equal(
-				boxedEditorUIView.element.firstChild.id );
-			expect( element.attributes.getNamedItem( 'role' ).value ).to.equal( 'application' );
-			expect( element.attributes.getNamedItem( 'lang' ).value ).to.equal( 'en' );
-		} );
-
-		it( 'bootstraps the view region elements from template', () => {
-			expect( topRegionEl.classList.contains( 'ck-editor__top' ) ).to.be.true;
-			expect( mainRegionEl.classList.contains( 'ck-editor__main' ) ).to.be.true;
-		} );
-
-		it( 'setups accessibility of the view region elements', () => {
-			expect( topRegionEl.attributes.getNamedItem( 'role' ).value ).to.equal( 'presentation' );
-			expect( mainRegionEl.attributes.getNamedItem( 'role' ).value ).to.equal( 'presentation' );
-		} );
-	} );
-} );

+ 0 - 57
packages/ckeditor5-ui/tests/editableui/editableui.js

@@ -1,57 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* globals document */
-/* bender-tags: editable */
-
-import StandardEditor from '/ckeditor5/core/editor/standardeditor.js';
-import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
-import EditableUIView from '/ckeditor5/ui/editableui/editableuiview.js';
-import testUtils from '/tests/utils/_utils/utils.js';
-
-describe( 'EditableUI', () => {
-	let editable, editableUI, editableUIView, editor;
-
-	beforeEach( () => {
-		editor = new StandardEditor();
-		editable = editor.editing.view.createRoot( document.createElement( 'div' ) );
-		editableUIView = new EditableUIView( editor.locale );
-		editableUI = new EditableUI( editable, editableUIView, editor );
-	} );
-
-	describe( 'constructor', () => {
-		it( 'sets all properties', () => {
-			expect( editableUI.editor ).to.equal( editor );
-		} );
-
-		it( 'binds editableUIView#model attributes to the editable', () => {
-			it( 'binds isFocused to editable.isFocused', () => {
-				testUtils.assertBinding(
-					editableUIView.model,
-					{ isFocused: false },
-					[
-						[ editable, { isFocused: true } ]
-					],
-					{ isFocused: true }
-				);
-			} );
-
-			it( 'binds isReadOnly to editable.isReadOnly', () => {
-				testUtils.assertBinding(
-					editableUIView.model,
-					{ isReadOnly: false },
-					[
-						[ editable, { isReadOnly: true } ]
-					],
-					{ isReadOnly: true }
-				);
-			} );
-		} );
-
-		it( 'sets editableUIView.model#name to editable#rootName', () => {
-			expect( editableUIView.model.name ).to.equal( editable.rootName );
-		} );
-	} );
-} );

+ 0 - 90
packages/ckeditor5-ui/tests/editableui/editableuiview.js

@@ -1,90 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* globals document */
-/* bender-tags: editable */
-
-import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
-import EditableUIView from '/ckeditor5/ui/editableui/editableuiview.js';
-import Model from '/ckeditor5/ui/model.js';
-import Locale from '/ckeditor5/utils/locale.js';
-
-describe( 'EditableUIView', () => {
-	let editable, view, editableElement, locale;
-
-	beforeEach( () => {
-		editable = new Model( {
-			isReadOnly: false,
-			isFocused: false,
-			rootName: 'foo'
-		} );
-		locale = new Locale( 'en' );
-		view = new EditableUIView( locale );
-		editableElement = document.createElement( 'div' );
-
-		return new EditableUI( editable, view ).init();
-	} );
-
-	describe( 'constructor', () => {
-		it( 'renders element from template when no editableElement', () => {
-			view = new EditableUIView( locale );
-			view.init();
-
-			expect( view.element ).to.equal( view.editableElement );
-			expect( view.element.classList.contains( 'ck-editor__editable' ) ).to.be.true;
-		} );
-
-		it( 'accepts editableElement as an argument', () => {
-			view = new EditableUIView( locale, editableElement );
-			view.init();
-
-			expect( view.element ).to.equal( editableElement );
-			expect( view.element ).to.equal( view.editableElement );
-			expect( view.element.classList.contains( 'ck-editor__editable' ) ).to.be.true;
-		} );
-	} );
-
-	describe( 'View bindings', () => {
-		describe( 'class', () => {
-			it( 'has initial value set', () => {
-				expect( view.element.classList.contains( 'ck-blurred' ) ).to.be.true;
-				expect( view.element.classList.contains( 'ck-focused' ) ).to.be.false;
-			} );
-
-			it( 'reacts on editable.isFocused', () => {
-				editable.isFocused = true;
-
-				expect( view.element.classList.contains( 'ck-blurred' ) ).to.be.false;
-				expect( view.element.classList.contains( 'ck-focused' ) ).to.be.true;
-			} );
-		} );
-
-		describe( 'contenteditable', () => {
-			it( 'has initial value set', () => {
-				expect( view.element.getAttribute( 'contenteditable' ) ).to.equal( 'true' );
-			} );
-
-			it( 'reacts on editable.isReadOnly', () => {
-				editable.isReadOnly = true;
-
-				expect( view.element.hasAttribute( 'contenteditable' ) ).to.be.false;
-			} );
-		} );
-	} );
-
-	describe( 'destroy', () => {
-		it( 'updates contentEditable property of editableElement', () => {
-			view = new EditableUIView( locale, editableElement );
-
-			return new EditableUI( editable, view ).init().then( () => {
-				expect( view.editableElement.contentEditable ).to.equal( 'true' );
-
-				view.destroy();
-
-				expect( view.editableElement.contentEditable ).to.equal( 'false' );
-			} );
-		} );
-	} );
-} );

+ 0 - 66
packages/ckeditor5-ui/tests/editableui/inline/inlineeditableuiview.js

@@ -1,66 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* globals document */
-/* bender-tags: editable */
-
-import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
-import InlineEditableUIView from '/ckeditor5/ui/editableui/inline/inlineeditableuiview.js';
-import Model from '/ckeditor5/ui/model.js';
-import Locale from '/ckeditor5/utils/locale.js';
-
-describe( 'InlineEditableUIView', () => {
-	let editable, view, editableElement, locale;
-
-	beforeEach( () => {
-		editable = new Model( {
-			isReadOnly: false,
-			isFocused: false,
-			rootName: 'foo'
-		} );
-		locale = new Locale( 'en' );
-		view = new InlineEditableUIView( locale );
-		editableElement = document.createElement( 'div' );
-
-		return new EditableUI( editable, view ).init();
-	} );
-
-	describe( 'constructor', () => {
-		it( 'accepts locale', () => {
-			expect( view.locale ).to.equal( locale );
-		} );
-
-		it( 'accepts editableElement', () => {
-			view = new InlineEditableUIView( locale, editableElement );
-
-			expect( view.element ).to.equal( editableElement );
-		} );
-
-		it( 'creates view#element from template when no editableElement provided', () => {
-			expect( view.template ).to.be.an( 'object' );
-		} );
-	} );
-
-	describe( 'editableElement', () => {
-		const ariaLabel = 'Rich Text Editor, foo';
-
-		it( 'has proper accessibility role', () => {
-			expect( view.element.attributes.getNamedItem( 'role' ).value ).to.equal( 'textbox' );
-		} );
-
-		it( 'has proper ARIA label', () => {
-			expect( view.element.getAttribute( 'aria-label' ) ).to.equal( ariaLabel );
-		} );
-
-		it( 'has proper title', () => {
-			expect( view.element.getAttribute( 'title' ) ).to.equal( ariaLabel );
-		} );
-
-		it( 'has proper class name', () => {
-			expect( view.element.classList.contains( 'ck-editor__editable' ) ).to.be.true;
-			expect( view.element.classList.contains( 'ck-editor__editable_inline' ) ).to.be.true;
-		} );
-	} );
-} );

+ 0 - 51
packages/ckeditor5-ui/tests/editorui/editorui.js

@@ -1,51 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-import testUtils from '/tests/core/_utils/utils.js';
-import Editor from '/ckeditor5/core/editor/editor.js';
-import EditorUI from '/ckeditor5/ui/editorui/editorui.js';
-import ComponentFactory from '/ckeditor5/ui/componentfactory.js';
-import ControllerCollection from '/ckeditor5/ui/controllercollection.js';
-
-testUtils.createSinonSandbox();
-
-describe( 'EditorUI', () => {
-	let editor, editorUI;
-
-	beforeEach( () => {
-		editor = new Editor();
-		editorUI = new EditorUI( editor );
-	} );
-
-	describe( 'constructor', () => {
-		it( 'sets all the properties', () => {
-			expect( editorUI ).to.have.property( 'editor', editor );
-
-			expect( editorUI.featureComponents ).to.be.instanceof( ComponentFactory );
-
-			expect( editorUI.collections.get( 'body' ) ).to.be.instanceof( ControllerCollection );
-		} );
-	} );
-
-	describe( 'init', () => {
-		it( 'calls _setupIconManager when "icon" in model', () => {
-			const spy = testUtils.sinon.spy( editorUI, '_setupIconManager' );
-
-			return editorUI.init()
-				.then( () => {
-					expect( spy.calledOnce ).to.be.true;
-				} );
-		} );
-	} );
-
-	describe( '_setupIconManager', () => {
-		it( 'sets "icon" property', () => {
-			editorUI._setupIconManager();
-
-			expect( editorUI.icons ).to.be.an( 'array' );
-			expect( editorUI.icons ).to.not.be.empty;
-		} );
-	} );
-} );

+ 0 - 37
packages/ckeditor5-ui/tests/editorui/editoruiview.js

@@ -1,37 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* globals document */
-
-import EditorUIView from '/ckeditor5/ui/editorui/editoruiview.js';
-
-describe( 'EditorUIView', () => {
-	let editorUIView;
-
-	beforeEach( () => {
-		editorUIView = new EditorUIView();
-
-		return editorUIView.init();
-	} );
-
-	describe( 'constructor', () => {
-		it( 'creates the body region', () => {
-			const el = editorUIView.regions.get( 'body' ).element;
-
-			expect( el.parentNode ).to.equal( document.body );
-			expect( el.nextSibling ).to.be.null;
-		} );
-	} );
-
-	describe( 'destroy', () => {
-		it( 'removes the body region container', () => {
-			const el = editorUIView.regions.get( 'body' ).element;
-
-			editorUIView.destroy();
-
-			expect( el.parentNode ).to.be.null;
-		} );
-	} );
-} );

+ 0 - 30
packages/ckeditor5-ui/tests/iconmanager/iconmanager.js

@@ -1,30 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: ui, iconmanager */
-
-import Model from '/ckeditor5/ui/model.js';
-import IconManager from '/ckeditor5/ui/iconmanager/iconmanager.js';
-import IconManagerView from '/ckeditor5/ui/iconmanager/iconmanagerview.js';
-
-describe( 'IconManager', () => {
-	let model, view;
-
-	beforeEach( () => {
-		view = new IconManagerView();
-		model = new Model( {
-			sprite: 'foo',
-			icons: [ 'bar' ]
-		} );
-
-		return new IconManager( model, view ).init();
-	} );
-
-	describe( 'constructor', () => {
-		it( 'binds view#model attributes to the IconManager#model', () => {
-			expect( view.model.sprite ).to.equal( model.sprite );
-		} );
-	} );
-} );

+ 0 - 39
packages/ckeditor5-ui/tests/iconmanager/iconmanagerview.js

@@ -1,39 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: ui, iconmanager */
-
-import testUtils from '/tests/core/_utils/utils.js';
-import IconManager from '/ckeditor5/ui/iconmanager/iconmanager.js';
-import IconManagerView from '/ckeditor5/ui/iconmanager/iconmanagerview.js';
-import Model from '/ckeditor5/ui/model.js';
-
-testUtils.createSinonSandbox();
-
-describe( 'IconManagerView', () => {
-	let model, view;
-
-	beforeEach( () => {
-		view = new IconManagerView();
-		model = new Model( {
-			sprite: '<symbol><title>foo</title></symbol>'
-		} );
-
-		return new IconManager( model, view ).init();
-	} );
-
-	describe( 'constructor', () => {
-		it( 'creates element from template', () => {
-			expect( view.element.tagName ).to.equal( 'svg' );
-			expect( view.element.getAttribute( 'class' ) ).to.equal( 'ck-icon-manager__sprite' );
-		} );
-	} );
-
-	describe( 'init', () => {
-		it( 'initializes the sprite', () => {
-			expect( view.element.innerHTML ).to.equal( '<symbol><title>foo</title></symbol>' );
-		} );
-	} );
-} );