|
@@ -0,0 +1,64 @@
|
|
|
|
|
+/**
|
|
|
|
|
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
|
|
|
|
|
+ * For licensing, see LICENSE.md.
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+import InlineEditorUIView from '../src/inlineeditoruiview';
|
|
|
|
|
+import FloatingToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/floating/floatingtoolbarview';
|
|
|
|
|
+import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
|
|
|
|
|
+import Locale from '@ckeditor/ckeditor5-utils/src/locale';
|
|
|
|
|
+
|
|
|
|
|
+describe( 'InlineEditorUIView', () => {
|
|
|
|
|
+ let locale, view;
|
|
|
|
|
+
|
|
|
|
|
+ beforeEach( () => {
|
|
|
|
|
+ locale = new Locale( 'en' );
|
|
|
|
|
+ view = new InlineEditorUIView( locale );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ describe( 'constructor()', () => {
|
|
|
|
|
+ describe( '#toolbar', () => {
|
|
|
|
|
+ it( 'is created', () => {
|
|
|
|
|
+ expect( view.toolbar ).to.be.instanceof( FloatingToolbarView );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'is given a locate object', () => {
|
|
|
|
|
+ expect( view.toolbar.locale ).to.equal( locale );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'is put into the "top" collection', () => {
|
|
|
|
|
+ expect( view.body.get( 0 ) ).to.equal( view.toolbar );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ describe( '#editable', () => {
|
|
|
|
|
+ it( 'is created', () => {
|
|
|
|
|
+ expect( view.editable ).to.be.instanceof( InlineEditableUIView );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'is given a locate object', () => {
|
|
|
|
|
+ expect( view.editable.locale ).to.equal( locale );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'is registered as a child', () => {
|
|
|
|
|
+ const spy = sinon.spy( view.editable, 'destroy' );
|
|
|
|
|
+
|
|
|
|
|
+ return view.init()
|
|
|
|
|
+ .then( () => view.destroy() )
|
|
|
|
|
+ .then( () => {
|
|
|
|
|
+ sinon.assert.calledOnce( spy );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ describe( 'editableElement', () => {
|
|
|
|
|
+ it( 'returns editable\'s view element', () => {
|
|
|
|
|
+ return view.init()
|
|
|
|
|
+ .then( () => {
|
|
|
|
|
+ expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
|
|
|
|
|
+ } )
|
|
|
|
|
+ .then( () => view.destroy() );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+} );
|