8
0

formats.js 1.7 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 ClassicTestEditor from '/tests/ckeditor5/_utils/classictesteditor.js';
  7. import Formats from '/ckeditor5/formats/formats.js';
  8. import FormatsEngine from '/ckeditor5/formats/formatsengine.js';
  9. import ListDropdown from '/ckeditor5/ui/dropdown/list/listdropdown.js';
  10. import testUtils from '/tests/ckeditor5/_utils/utils.js';
  11. testUtils.createSinonSandbox();
  12. describe( 'Formats', () => {
  13. let editor;
  14. beforeEach( () => {
  15. return ClassicTestEditor.create( document.getElementById( 'editor' ), {
  16. features: [ Formats ],
  17. toolbar: [ 'formats' ]
  18. } )
  19. .then( newEditor => {
  20. editor = newEditor;
  21. } );
  22. } );
  23. afterEach( () => {
  24. return editor.destroy();
  25. } );
  26. it( 'should be loaded', () => {
  27. expect( editor.plugins.get( Formats ) ).to.be.instanceOf( Formats );
  28. } );
  29. it( 'should load FormatsEngine', () => {
  30. expect( editor.plugins.get( FormatsEngine ) ).to.be.instanceOf( FormatsEngine );
  31. } );
  32. it( 'should register formats feature component', () => {
  33. const controller = editor.ui.featureComponents.create( 'formats' );
  34. expect( controller ).to.be.instanceOf( ListDropdown );
  35. } );
  36. it( 'should execute format command on model execute event', () => {
  37. const executeSpy = testUtils.sinon.spy( editor, 'execute' );
  38. const controller = editor.ui.featureComponents.create( 'formats' );
  39. const model = controller.model.content;
  40. model.fire( 'execute', { id: 'paragraph', label: 'Paragraph' } );
  41. sinon.assert.calledOnce( executeSpy );
  42. sinon.assert.calledWithExactly( executeSpy, 'format', 'paragraph' );
  43. } );
  44. } );