nooperation.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: document */
  6. 'use strict';
  7. const modules = bender.amd.require(
  8. 'document/document',
  9. 'document/operation/nooperation'
  10. );
  11. describe( 'NoOperation', () => {
  12. let Document, NoOperation;
  13. before( function() {
  14. Document = modules[ 'document/document' ];
  15. NoOperation = modules[ 'document/operation/nooperation' ];
  16. } );
  17. let noop, doc, root;
  18. beforeEach( () => {
  19. noop = new NoOperation( 0 );
  20. doc = new Document();
  21. root = doc.createRoot( 'root' );
  22. } );
  23. it( 'should not throw an error when applied', () => {
  24. expect( () => doc.applyOperation( noop ) ).to.not.throw( Error );
  25. } );
  26. it( 'should create a do-nothing operation as a reverse', () => {
  27. const reverse = noop.getReversed();
  28. expect( reverse ).to.be.an.instanceof( NoOperation );
  29. expect( reverse.baseVersion ).to.equal( 1 );
  30. } );
  31. it( 'should create a do-nothing operation having same parameters when cloned', () => {
  32. const clone = noop.clone();
  33. expect( clone ).to.be.an.instanceof( NoOperation );
  34. expect( clone.baseVersion ).to.equal( 0 );
  35. } );
  36. } );