8
0

editableui.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. 'use strict';
  7. import StandardEditor from '/ckeditor5/editor/standardeditor.js';
  8. import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
  9. import Model from '/ckeditor5/ui/model.js';
  10. import testUtils from '/tests/utils/_utils/utils.js';
  11. describe( 'EditableUI', () => {
  12. let editable, editableUI, editor;
  13. beforeEach( () => {
  14. editor = new StandardEditor();
  15. editable = editor.editing.view.createRoot( document.createElement( 'div' ) );
  16. editableUI = new EditableUI( editor, editable );
  17. } );
  18. describe( 'constructor', () => {
  19. it( 'sets all properties', () => {
  20. expect( editableUI.editor ).to.equal( editor );
  21. expect( editableUI.viewModel ).to.be.instanceof( Model );
  22. } );
  23. } );
  24. describe( 'viewModel', () => {
  25. it( 'constains observable attributes', () => {
  26. expect( editableUI.viewModel ).to.have.property( 'isReadOnly', false );
  27. expect( editableUI.viewModel ).to.have.property( 'isFocused', false );
  28. } );
  29. it( 'binds isFocused to editable.isFocused', () => {
  30. testUtils.assertBinding(
  31. editableUI.viewModel,
  32. { isFocused: false },
  33. [
  34. [ editable, { isFocused: true } ]
  35. ],
  36. { isFocused: true }
  37. );
  38. } );
  39. it( 'binds isReadOnly to editable.isReadOnly', () => {
  40. testUtils.assertBinding(
  41. editableUI.viewModel,
  42. { isReadOnly: false },
  43. [
  44. [ editable, { isReadOnly: true } ]
  45. ],
  46. { isReadOnly: true }
  47. );
  48. } );
  49. } );
  50. } );