editableui.js 1.5 KB

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