basecommand.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import ModelTestEditor from '/tests/ckeditor5/_utils/modeltesteditor.js';
  7. import BaseCommand from '/ckeditor5/undo/basecommand.js';
  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( 'BaseCommand', () => {
  19. describe( 'constructor', () => {
  20. it( 'should create command with empty batch stack', () => {
  21. expect( base._checkEnabled() ).to.be.false;
  22. } );
  23. } );
  24. describe( '_checkEnabled', () => {
  25. it( 'should return false if there are no batches in command stack', () => {
  26. expect( base._checkEnabled() ).to.be.false;
  27. } );
  28. it( 'should return true if there are batches in command stack', () => {
  29. base.addBatch( doc.batch() );
  30. expect( base._checkEnabled() ).to.be.true;
  31. } );
  32. } );
  33. describe( 'clearStack', () => {
  34. it( 'should remove all batches from the stack', () => {
  35. base.addBatch( doc.batch() );
  36. base.clearStack();
  37. expect( base._checkEnabled() ).to.be.false;
  38. } );
  39. } );
  40. } );