basecommand.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 BaseCommand from '../src/basecommand';
  7. describe( 'BaseCommand', () => {
  8. let editor, doc, base;
  9. beforeEach( () => {
  10. editor = new ModelTestEditor();
  11. base = new BaseCommand( editor );
  12. doc = editor.document;
  13. } );
  14. afterEach( () => {
  15. base.destroy();
  16. } );
  17. describe( 'constructor()', () => {
  18. it( 'should create command with empty batch stack', () => {
  19. expect( base._checkEnabled() ).to.be.false;
  20. } );
  21. } );
  22. describe( '_checkEnabled', () => {
  23. it( 'should return false if there are no batches in command stack', () => {
  24. expect( base._checkEnabled() ).to.be.false;
  25. } );
  26. it( 'should return true if there are batches in command stack', () => {
  27. base.addBatch( doc.batch() );
  28. expect( base._checkEnabled() ).to.be.true;
  29. } );
  30. } );
  31. describe( 'clearStack', () => {
  32. it( 'should remove all batches from the stack', () => {
  33. base.addBatch( doc.batch() );
  34. base.clearStack();
  35. expect( base._checkEnabled() ).to.be.false;
  36. } );
  37. } );
  38. } );