浏览代码

Updated tests to pass with recent changes.

Piotrek Koszuliński 9 年之前
父节点
当前提交
99fa3eb49d

+ 4 - 4
packages/ckeditor5-ui/src/editableui/editableui.js

@@ -17,9 +17,9 @@ export default class EditableUI extends Controller {
 	 * Creates a new instance of the Editable class.
 	 *
 	 * @param {ckeditor5.Editor} editor The editor instance.
-	 * @param {engine.view.RootEditableElement} editableModel The model for the editable.
+	 * @param {engine.view.RootEditableElement} editable The editable element.
 	 */
-	constructor( editor, editableModel ) {
+	constructor( editor, editable ) {
 		super();
 
 		/**
@@ -38,7 +38,7 @@ export default class EditableUI extends Controller {
 		 */
 		this.viewModel = new Model();
 
-		this.viewModel.bind( 'isReadOnly', 'isFocused' ).to( editableModel );
-		this.viewModel.set( 'name', editableModel.rootName );
+		this.viewModel.bind( 'isReadOnly', 'isFocused' ).to( editable );
+		this.viewModel.set( 'name', editable.rootName );
 	}
 }

+ 8 - 8
packages/ckeditor5-ui/src/editableui/editableuiview.js

@@ -17,7 +17,7 @@ export default class EditableUIView extends View {
 	 *
 	 * @param {utils.Observable} model (View)Model of this View.
 	 * @param {utils.Locale} [locale] The {@link ckeditor5.Editor#locale editor's locale} instance.
-	 * @param {HTMLElement} [editableElement] The editable element. If not specified, this View
+	 * @param {HTMLElement} [editableElement] The editable element. If not specified, this view
 	 * should create it. Otherwise, the existing element should be used.
 	 */
 	constructor( model, locale, editableElement ) {
@@ -39,6 +39,13 @@ export default class EditableUIView extends View {
 				contenteditable: bind.to( 'isReadOnly', value => !value ),
 			}
 		};
+
+		/**
+		 * The element which is the main editable element (usually the one with `contentEditable="true"`).
+		 *
+		 * @readonly
+		 * @member {HTMLElement} ui.editableUI.EditableUIView#editableElement
+		 */
 	}
 
 	/**
@@ -60,11 +67,4 @@ export default class EditableUIView extends View {
 
 		this.editableElement.contentEditable = false;
 	}
-
-	/**
-	 * The element which is the main editable element (usually the one with `contentEditable="true"`).
-	 *
-	 * @readonly
-	 * @member {HTMLElement} ui.editableUI.EditableUIView#editableElement
-	 */
 }

+ 1 - 1
packages/ckeditor5-ui/tests/bindings/toolbar.js

@@ -7,7 +7,7 @@
 
 'use strict';
 
-import Editor from '/ckeditor5/editor.js';
+import Editor from '/ckeditor5/editor/editor.js';
 import Model from '/ckeditor5/ui/model.js';
 import View from '/ckeditor5/ui/view.js';
 import Controller from '/ckeditor5/ui/controller.js';

+ 1 - 1
packages/ckeditor5-ui/tests/boxededitorui/boxededitorui.js

@@ -5,7 +5,7 @@
 
 'use strict';
 
-import Editor from '/ckeditor5/editor.js';
+import Editor from '/ckeditor5/editor/editor.js';
 import BoxedEditorUI from '/ckeditor5/ui/editorui/boxed/boxededitorui.js';
 import ControllerCollection from '/ckeditor5/ui/controllercollection.js';
 

+ 1 - 1
packages/ckeditor5-ui/tests/componentfactory.js

@@ -7,7 +7,7 @@
 
 'use strict';
 
-import Editor from '/ckeditor5/editor.js';
+import Editor from '/ckeditor5/editor/editor.js';
 import ComponentFactory from '/ckeditor5/ui/componentfactory.js';
 import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
 

+ 8 - 9
packages/ckeditor5-ui/tests/editableui/editableui.js

@@ -7,8 +7,7 @@
 
 'use strict';
 
-import Editor from '/ckeditor5/editor.js';
-import Editable from '/ckeditor5/editable.js';
+import StandardEditor from '/ckeditor5/editor/standardeditor.js';
 import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
 import Model from '/ckeditor5/ui/model.js';
 import testUtils from '/tests/utils/_utils/utils.js';
@@ -17,8 +16,8 @@ describe( 'EditableUI', () => {
 	let editable, editableUI, editor;
 
 	beforeEach( () => {
-		editor = new Editor();
-		editable = new Editable( editor, 'foo' );
+		editor = new StandardEditor();
+		editable = editor.editing.view.createRoot( document.createElement( 'div' ) );
 		editableUI = new EditableUI( editor, editable );
 	} );
 
@@ -31,7 +30,7 @@ describe( 'EditableUI', () => {
 
 	describe( 'viewModel', () => {
 		it( 'constains observable attributes', () => {
-			expect( editableUI.viewModel ).to.have.property( 'isEditable', true );
+			expect( editableUI.viewModel ).to.have.property( 'isReadOnly', false );
 			expect( editableUI.viewModel ).to.have.property( 'isFocused', false );
 		} );
 
@@ -46,14 +45,14 @@ describe( 'EditableUI', () => {
 			);
 		} );
 
-		it( 'binds isEditable to editable.isEditable', () => {
+		it( 'binds isReadOnly to editable.isReadOnly', () => {
 			testUtils.assertBinding(
 				editableUI.viewModel,
-				{ isEditable: true },
+				{ isReadOnly: false },
 				[
-					[ editable, { isEditable: false } ]
+					[ editable, { isReadOnly: true } ]
 				],
-				{ isEditable: false }
+				{ isReadOnly: true }
 			);
 		} );
 	} );

+ 5 - 5
packages/ckeditor5-ui/tests/editableui/editableuiview.js

@@ -15,7 +15,7 @@ describe( 'EditableUIView', () => {
 	let model, view, editableElement, locale;
 
 	beforeEach( () => {
-		model = new Model( { isEditable: true, isFocused: false } );
+		model = new Model( { isReadOnly: false, isFocused: false } );
 		locale = new Locale( 'en' );
 		view = new EditableUIView( model, locale );
 		editableElement = document.createElement( 'div' );
@@ -59,13 +59,13 @@ describe( 'EditableUIView', () => {
 
 		describe( 'contenteditable', () => {
 			it( 'has initial value set', () => {
-				expect( view.element.attributes.getNamedItem( 'contenteditable' ).value ).to.equal( 'true' );
+				expect( view.element.getAttribute( 'contenteditable' ) ).to.equal( 'true' );
 			} );
 
-			it( 'reacts on model.isEditable', () => {
-				model.isEditable = false;
+			it( 'reacts on model.isReadOnly', () => {
+				model.isReadOnly = true;
 
-				expect( view.element.attributes.getNamedItem( 'contenteditable' ).value ).to.equal( 'false' );
+				expect( view.element.getAttribute( 'contenteditable' ) ).to.equal( 'false' );
 			} );
 		} );
 	} );

+ 5 - 3
packages/ckeditor5-ui/tests/editableui/inline/inlineeditableuiview.js

@@ -15,7 +15,7 @@ describe( 'InlineEditableUIView', () => {
 	let model, view, editableElement, locale;
 
 	beforeEach( () => {
-		model = new Model( { isEditable: true, isFocused: false } );
+		model = new Model( { isEditable: true, isFocused: false, name: 'foo' } );
 		locale = new Locale( 'en' );
 		view = new InlineEditableUIView( model, locale );
 		editableElement = document.createElement( 'div' );
@@ -44,16 +44,18 @@ describe( 'InlineEditableUIView', () => {
 	} );
 
 	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.attributes.getNamedItem( 'aria-label' ).value ).to.be.a( 'string' );
+			expect( view.element.getAttribute( 'aria-label' ) ).to.equal( ariaLabel );
 		} );
 
 		it( 'has proper title', () => {
-			expect( view.element.attributes.getNamedItem( 'title' ).value ).to.be.a( 'string' );
+			expect( view.element.getAttribute( 'title' ) ).to.equal( ariaLabel );
 		} );
 
 		it( 'has proper class name', () => {

+ 1 - 1
packages/ckeditor5-ui/tests/editorui/editorui.js

@@ -6,7 +6,7 @@
 'use strict';
 
 import testUtils from '/tests/ckeditor5/_utils/utils.js';
-import Editor from '/ckeditor5/editor.js';
+import Editor from '/ckeditor5/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';