8
0

basecommand.js 1.2 KB

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