basecommand.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
  6. import BaseCommand from '../src/basecommand';
  7. describe( 'BaseCommand', () => {
  8. let editor, base;
  9. beforeEach( () => {
  10. editor = new ModelTestEditor();
  11. base = new BaseCommand( editor );
  12. } );
  13. afterEach( () => {
  14. base.destroy();
  15. } );
  16. describe( 'constructor()', () => {
  17. it( 'should create command with empty batch stack', () => {
  18. expect( base.isEnabled ).to.be.false;
  19. } );
  20. } );
  21. describe( 'isEnabled', () => {
  22. it( 'should be false if there are no batches in command stack', () => {
  23. expect( base.isEnabled ).to.be.false;
  24. } );
  25. it( 'should be true if there are batches in command stack', () => {
  26. base.addBatch( editor.model.createBatch() );
  27. expect( base.isEnabled ).to.be.true;
  28. } );
  29. } );
  30. describe( 'clearStack', () => {
  31. it( 'should remove all batches from the stack', () => {
  32. base.addBatch( editor.model.createBatch() );
  33. base.clearStack();
  34. expect( base.isEnabled ).to.be.false;
  35. } );
  36. } );
  37. } );