editableui.js 1.6 KB

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