toolbar.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: ui, bindings, toolbar */
  6. import Editor from '/ckeditor5/core/editor/editor.js';
  7. import Model from '/ckeditor5/ui/model.js';
  8. import View from '/ckeditor5/ui/view.js';
  9. import Controller from '/ckeditor5/ui/controller.js';
  10. import Toolbar from '/ckeditor5/ui/bindings/toolbar.js';
  11. import testUtils from '/tests/core/_utils/utils.js';
  12. testUtils.createSinonSandbox();
  13. describe( 'Toolbar', () => {
  14. let toolbar, model;
  15. const editor = new Editor();
  16. editor.ui = {
  17. featureComponents: {
  18. create: () => new Controller()
  19. }
  20. };
  21. beforeEach( () => {
  22. model = new Model( {
  23. isActive: false,
  24. config: [ 'bold', 'italic' ]
  25. } );
  26. toolbar = new Toolbar( model, new View(), editor );
  27. } );
  28. describe( 'constructor', () => {
  29. it( 'sets all the properties', () => {
  30. expect( toolbar ).to.have.property( 'editor', editor );
  31. } );
  32. } );
  33. describe( 'init', () => {
  34. it( 'calls bindToolbarItems', () => {
  35. const spy = testUtils.sinon.spy( toolbar, 'bindToolbarItems' );
  36. return toolbar.init().then( () => {
  37. expect( spy.calledOnce ).to.be.true;
  38. } );
  39. } );
  40. } );
  41. } );