basecommand.js 1.2 KB

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