| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- /* bender-tags: treemodel, delta */
- 'use strict';
- import coreTestUtils from '/tests/core/_utils/utils.js';
- import Delta from '/ckeditor5/core/treemodel/delta/delta.js';
- const getIteratorCount = coreTestUtils.getIteratorCount;
- describe( 'Delta', () => {
- describe( 'constructor', () => {
- it( 'should create an delta with empty properties', () => {
- const delta = new Delta();
- expect( delta ).to.have.property( 'batch' ).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.operations );
- expect( count ).to.equal( 3 );
- } );
- } );
- } );
|