8
0

markerdelta.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import Document from '../../../src/model/document';
  6. import Range from '../../../src/model/range';
  7. import MarkerDelta from '../../../src/model/delta/markerdelta';
  8. import MarkerOperation from '../../../src/model/operation/markeroperation';
  9. describe( 'MarkerDelta', () => {
  10. let markerDelta, doc, root, range;
  11. beforeEach( () => {
  12. doc = new Document();
  13. root = doc.createRoot();
  14. range = Range.createIn( root );
  15. markerDelta = new MarkerDelta();
  16. } );
  17. describe( 'constructor()', () => {
  18. it( 'should create merge delta with no operations added', () => {
  19. expect( markerDelta.operations.length ).to.equal( 0 );
  20. } );
  21. } );
  22. describe( 'type', () => {
  23. it( 'should be equal to marker', () => {
  24. expect( markerDelta.type ).to.equal( 'marker' );
  25. } );
  26. } );
  27. describe( 'getReversed', () => {
  28. it( 'should return correct MarkerDelta', () => {
  29. markerDelta.addOperation( new MarkerOperation( 'name', null, range, 0 ) );
  30. const reversed = markerDelta.getReversed();
  31. expect( reversed ).to.be.instanceof( MarkerDelta );
  32. expect( reversed.operations.length ).to.equal( 1 );
  33. const op = reversed.operations[ 0 ];
  34. expect( op ).to.be.an.instanceof( MarkerOperation );
  35. expect( op.oldRange.isEqual( range ) ).to.be.true;
  36. expect( op.newRange ).to.be.null;
  37. } );
  38. } );
  39. it( 'should provide proper className', () => {
  40. expect( MarkerDelta.className ).to.equal( 'engine.model.delta.MarkerDelta' );
  41. } );
  42. } );