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

Tests: Added tests for BoxedEditorUI and BoxedEditorUIView.

Aleksander Nowodzinski 9 лет назад
Родитель
Сommit
1b0e7af813

+ 4 - 0
packages/ckeditor5-ui/src/boxededitorui/boxededitorui.js

@@ -18,11 +18,15 @@ export default class BoxedEditorUI extends EditorUI {
 		const config = editor.config;
 
 		/**
+		 * TODO: Handle editor resizing.
+		 *
 		 * @property {Number} width
 		 */
 		this.set( 'width', config.get( 'ui.width' ) );
 
 		/**
+		 * TODO: Handle editor resizing.
+		 *
 		 * @property {Number} height
 		 */
 		this.set( 'height', config.get( 'ui.height' ) );

+ 4 - 4
packages/ckeditor5-ui/src/boxededitorui/boxededitoruiview.js

@@ -41,21 +41,21 @@ export default class BoxedEditorUIView extends EditorUIView {
 				{
 					tag: 'div',
 					attributes: {
-						class: 'ck-editor-top ck-reset-all',
+						class: 'ck-editor__top ck-reset-all',
 						role: 'presentation'
 					}
 				},
 				{
 					tag: 'div',
 					attributes: {
-						class: 'ck-editor-main',
+						class: 'ck-editor__main',
 						role: 'presentation'
 					}
 				}
 			]
 		};
 
-		this.register( 'top', '.ck-editor-top' );
-		this.register( 'main', '.ck-editor-main' );
+		this.register( 'top', '.ck-editor__top' );
+		this.register( 'main', '.ck-editor__main' );
 	}
 }

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

@@ -0,0 +1,42 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import Editor from '/ckeditor5/editor.js';
+import BoxedEditorUI from '/ckeditor5/ui/boxededitorui/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' ) );
+		} );
+	} );
+
+	describe( 'viewModel', () => {
+		it( 'points to the BoxedEditorUI instance', () => {
+			expect( boxedEditorUI.viewModel ).to.equal( boxedEditorUI );
+		} );
+	} );
+} );

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

@@ -0,0 +1,53 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import BoxedEditorUIView from '/ckeditor5/ui/boxededitorui/boxededitoruiview.js';
+import Model from '/ckeditor5/ui/model.js';
+import Locale from '/ckeditor5/utils/locale.js';
+
+describe( 'BoxedEditorUIView', () => {
+	let boxedEditorUIView, element, topRegionEl, mainRegionEl;
+
+	beforeEach( () => {
+		boxedEditorUIView = new BoxedEditorUIView( new Model(), 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' );
+		} );
+	} );
+} );