8
0

deltareplayer.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import DeltaReplayer from '../../src/dev-utils/deltareplayer';
  6. import Document from '../../src/model/document';
  7. describe( 'DeltaReplayer', () => {
  8. describe( 'constructor()', () => {
  9. it( 'should be able to initialize replayer without deltas', () => {
  10. const fakeDocument = {};
  11. const stringifiedDeltas = '';
  12. const deltaReplayer = new DeltaReplayer( fakeDocument, '---', stringifiedDeltas );
  13. expect( deltaReplayer._deltasToReplay ).to.deep.equal( [] );
  14. expect( deltaReplayer._document ).to.deep.equal( fakeDocument );
  15. expect( deltaReplayer._logSeparator ).to.deep.equal( '---' );
  16. } );
  17. it( 'should be able to initialize replayer with deltas', () => {
  18. const doc = new Document();
  19. doc.createRoot( 'main' );
  20. const delta = {
  21. operations: [ {
  22. baseVersion: 0,
  23. position: {
  24. root: 'main',
  25. path: [ 0 ]
  26. },
  27. nodes: [ {
  28. name: 'heading1',
  29. children: [ {
  30. data: 'The great world of open Web standards'
  31. } ]
  32. } ],
  33. __className: 'engine.model.operation.InsertOperation'
  34. } ],
  35. __className: 'engine.model.delta.InsertDelta'
  36. };
  37. const deltaReplayer = new DeltaReplayer( doc, '---', JSON.stringify( delta ) );
  38. expect( deltaReplayer._deltasToReplay ).to.deep.equal( [ delta ] );
  39. } );
  40. } );
  41. } );