indent.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* global document */
  6. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  7. import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
  8. import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
  9. import Indent from '../src/indent';
  10. import MultiCommand from '../src/multicommand';
  11. describe( 'indent', () => {
  12. let editor, element;
  13. testUtils.createSinonSandbox();
  14. beforeEach( () => {
  15. element = document.createElement( 'div' );
  16. document.body.appendChild( element );
  17. return ClassicTestEditor
  18. .create( element, { plugins: [ Indent ] } )
  19. .then( newEditor => {
  20. editor = newEditor;
  21. } );
  22. } );
  23. afterEach( () => {
  24. element.remove();
  25. if ( editor ) {
  26. return editor.destroy();
  27. }
  28. } );
  29. it( 'should be named', () => {
  30. expect( Indent.pluginName ).to.equal( 'Indent' );
  31. } );
  32. it( 'should be loaded', () => {
  33. expect( editor.plugins.get( Indent ) ).to.be.instanceOf( Indent );
  34. } );
  35. it( 'should register indent command', () => {
  36. const command = editor.commands.get( 'indent' );
  37. expect( command ).to.be.instanceof( MultiCommand );
  38. } );
  39. it( 'should register outdent command', () => {
  40. const command = editor.commands.get( 'outdent' );
  41. expect( command ).to.be.instanceof( MultiCommand );
  42. } );
  43. it( 'should set up button for indent', () => {
  44. const indentButton = editor.ui.componentFactory.create( 'indent' );
  45. expect( indentButton ).to.be.instanceOf( ButtonView );
  46. } );
  47. it( 'should set up button for indent', () => {
  48. const outdentButton = editor.ui.componentFactory.create( 'outdent' );
  49. expect( outdentButton ).to.be.instanceOf( ButtonView );
  50. } );
  51. } );