editorui.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 testUtils from '/tests/ckeditor5/_utils/utils.js';
  7. import Editor from '/ckeditor5/editor/editor.js';
  8. import EditorUI from '/ckeditor5/ui/editorui/editorui.js';
  9. import ComponentFactory from '/ckeditor5/ui/componentfactory.js';
  10. import ControllerCollection from '/ckeditor5/ui/controllercollection.js';
  11. testUtils.createSinonSandbox();
  12. describe( 'EditorUI', () => {
  13. let editor, editorUI;
  14. beforeEach( () => {
  15. editor = new Editor();
  16. editorUI = new EditorUI( editor );
  17. } );
  18. describe( 'constructor', () => {
  19. it( 'sets all the properties', () => {
  20. expect( editorUI ).to.have.property( 'editor', editor );
  21. expect( editorUI.featureComponents ).to.be.instanceof( ComponentFactory );
  22. expect( editorUI.collections.get( 'body' ) ).to.be.instanceof( ControllerCollection );
  23. } );
  24. it( 'sets editor.ui property', () => {
  25. expect( editor ).to.have.property( 'ui', editorUI );
  26. } );
  27. } );
  28. describe( 'init', () => {
  29. it( 'calls _setupIconManager when "icon" in model', () => {
  30. const spy = testUtils.sinon.spy( editorUI, '_setupIconManager' );
  31. return editorUI.init()
  32. .then( () => {
  33. expect( spy.calledOnce ).to.be.true;
  34. } );
  35. } );
  36. } );
  37. describe( '_setupIconManager', () => {
  38. it( 'sets "icon" property', () => {
  39. editorUI._setupIconManager();
  40. expect( editorUI.icons ).to.be.an( 'array' );
  41. expect( editorUI.icons ).to.not.be.empty;
  42. } );
  43. } );
  44. } );