8
0

operation.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. var modules = bender.amd.require( 'document/operation', 'document/character' );
  8. describe( 'uncompress', function() {
  9. it( 'should change array of strings into a set of nodes', function() {
  10. var Operation = modules[ 'document/operation' ];
  11. var Character = modules[ 'document/character' ];
  12. var uncompressed = Operation.uncompress( [ 'foo', new Character( null, 'x' ), 'bar' ] );
  13. expect( uncompressed.length ).to.be.equal( 7 );
  14. expect( uncompressed[ 0 ].character ).to.be.equal( 'f' );
  15. expect( uncompressed[ 1 ].character ).to.be.equal( 'o' );
  16. expect( uncompressed[ 2 ].character ).to.be.equal( 'o' );
  17. expect( uncompressed[ 3 ].character ).to.be.equal( 'x' );
  18. expect( uncompressed[ 4 ].character ).to.be.equal( 'b' );
  19. expect( uncompressed[ 5 ].character ).to.be.equal( 'a' );
  20. expect( uncompressed[ 6 ].character ).to.be.equal( 'r' );
  21. } );
  22. it( 'should change string into a set of nodes', function() {
  23. var Operation = modules[ 'document/operation' ];
  24. var uncompressed = Operation.uncompress( 'foo' );
  25. expect( uncompressed.length ).to.be.equal( 3 );
  26. expect( uncompressed[ 0 ].character ).to.be.equal( 'f' );
  27. expect( uncompressed[ 1 ].character ).to.be.equal( 'o' );
  28. expect( uncompressed[ 2 ].character ).to.be.equal( 'o' );
  29. } );
  30. it( 'should change node into a set of nodes', function() {
  31. var Operation = modules[ 'document/operation' ];
  32. var Character = modules[ 'document/character' ];
  33. var uncompressed = Operation.uncompress( new Character( null, 'x' ) );
  34. expect( uncompressed.length ).to.be.equal( 1 );
  35. expect( uncompressed[ 0 ].character ).to.be.equal( 'x' );
  36. } );
  37. } );