editableui.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: editable */
  6. import StandardEditor from '/ckeditor5/core/editor/standardeditor.js';
  7. import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
  8. import EditableUIView from '/ckeditor5/ui/editableui/editableuiview.js';
  9. import testUtils from '/tests/utils/_utils/utils.js';
  10. describe( 'EditableUI', () => {
  11. let editable, editableUI, editableUIView, editor;
  12. beforeEach( () => {
  13. editor = new StandardEditor();
  14. editable = editor.editing.view.createRoot( document.createElement( 'div' ) );
  15. editableUIView = new EditableUIView( editor.locale );
  16. editableUI = new EditableUI( editable, editableUIView, editor );
  17. } );
  18. describe( 'constructor', () => {
  19. it( 'sets all properties', () => {
  20. expect( editableUI.editor ).to.equal( editor );
  21. } );
  22. it( 'binds editableUIView#model attributes to the editable', () => {
  23. it( 'binds isFocused to editable.isFocused', () => {
  24. testUtils.assertBinding(
  25. editableUIView.model,
  26. { isFocused: false },
  27. [
  28. [ editable, { isFocused: true } ]
  29. ],
  30. { isFocused: true }
  31. );
  32. } );
  33. it( 'binds isReadOnly to editable.isReadOnly', () => {
  34. testUtils.assertBinding(
  35. editableUIView.model,
  36. { isReadOnly: false },
  37. [
  38. [ editable, { isReadOnly: true } ]
  39. ],
  40. { isReadOnly: true }
  41. );
  42. } );
  43. } );
  44. it( 'sets editableUIView.model#name to editable#rootName', () => {
  45. expect( editableUIView.model.name ).to.equal( editable.rootName );
  46. } );
  47. } );
  48. } );