| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- /* bender-tags: document, delta */
- /* bender-include: ../../_tools/tools.js */
- 'use strict';
- const getIteratorCount = bender.tools.core.getIteratorCount;
- const modules = bender.amd.require(
- 'document/delta/delta' );
- describe( 'Delta', () => {
- let Delta;
- before( () => {
- Delta = modules[ 'document/delta/delta' ];
- } );
- describe( 'constructor', () => {
- it( 'should create an delta with empty properties', () => {
- const delta = new Delta();
- expect( delta ).to.have.property( 'transaction' ).that.is.null;
- expect( delta ).to.have.property( 'operations' ).that.a( 'array' ).and.have.length( 0 );
- } );
- } );
- describe( 'addOperation', () => {
- it( 'should add operation to the delta', () => {
- const delta = new Delta();
- const operation = {};
- delta.addOperation( operation );
- expect( delta.operations ).to.have.length( 1 );
- expect( delta.operations[ 0 ] ).to.equal( operation );
- } );
- it( 'should add delta property to the operation', () => {
- const delta = new Delta();
- const operation = {};
- delta.addOperation( operation );
- expect( operation.delta ).to.equal( delta );
- } );
- } );
- describe( 'iterator', () => {
- it( 'should iterate over delta operations', () => {
- const delta = new Delta();
- delta.addOperation( {} );
- delta.addOperation( {} );
- delta.addOperation( {} );
- const count = getIteratorCount( delta );
- expect( count ).to.equal( 3 );
- } );
- } );
- } );
|