editable.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import Editor from '/ckeditor5/core/editor.js';
  7. import Editable from '/ckeditor5/core/editable/editable.js';
  8. import Model from '/ckeditor5/core/ui/model.js';
  9. import coreTestUtils from '/tests/core/_utils/utils.js';
  10. describe( 'Editable', () => {
  11. let editable, editor;
  12. beforeEach( () => {
  13. editor = new Editor();
  14. editable = new Editable( editor );
  15. } );
  16. describe( 'constructor', () => {
  17. it( 'sets all the properties', () => {
  18. expect( editable ).to.have.property( 'editor', editor );
  19. expect( editable ).to.have.property( 'isFocused', false );
  20. expect( editable ).to.have.property( 'isEditable', true );
  21. } );
  22. } );
  23. describe( 'viewModel', () => {
  24. it( 'returns a model instance', () => {
  25. expect( editable.viewModel ).to.be.an.instanceof( Model );
  26. } );
  27. it( 'always returns the same instance', () => {
  28. expect( editable.viewModel ).to.equal( editable.viewModel );
  29. } );
  30. it( 'constains editable attributes', () => {
  31. expect( editable.viewModel ).to.have.property( 'isEditable', true );
  32. expect( editable.viewModel ).to.have.property( 'isFocused', false );
  33. } );
  34. it( 'binds this.isFocused to editable', () => {
  35. coreTestUtils.assertBinding(
  36. editable,
  37. { isFocused: false },
  38. [
  39. [ editable.viewModel, { isFocused: true } ]
  40. ],
  41. { isFocused: true }
  42. );
  43. } );
  44. it( 'binds editable.isEditable to itself', () => {
  45. coreTestUtils.assertBinding(
  46. editable.viewModel,
  47. { isEditable: true },
  48. [
  49. [ editable, { isEditable: false } ]
  50. ],
  51. { isEditable: false }
  52. );
  53. } );
  54. } );
  55. // These are temporary implementation, so tests do nothing beside ensuring 100% CC.
  56. describe( 'getData() and setData()', () => {
  57. it( 'exist', () => {
  58. editable.view = {
  59. editableElement: document.createElement( 'div' )
  60. };
  61. editable.getData();
  62. editable.setData();
  63. } );
  64. } );
  65. } );