| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /**
- * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- import Batch from '../../src/model/batch';
- import Operation from '../../src/model/operation/operation';
- describe( 'Batch', () => {
- describe( 'type', () => {
- it( 'should default to "default"', () => {
- const batch = new Batch();
- expect( batch.type ).to.equal( 'default' );
- } );
- it( 'should be set to the value set in constructor', () => {
- const batch = new Batch( 'transparent' );
- expect( batch.type ).to.equal( 'transparent' );
- } );
- } );
- describe( 'addOperation()', () => {
- it( 'should add operation to the batch', () => {
- const batch = new Batch();
- const op = new Operation( 0 );
- batch.addOperation( op );
- expect( batch.operations.length ).to.equal( 1 );
- expect( batch.operations[ 0 ] ).to.equal( op );
- } );
- } );
- describe( 'baseVersion', () => {
- it( 'should return base version of the first operation from the batch', () => {
- const batch = new Batch();
- const operation = new Operation( 2 );
- batch.addOperation( operation );
- expect( batch.baseVersion ).to.equal( 2 );
- } );
- it( 'should return null if there are no operations in batch', () => {
- const batch = new Batch();
- expect( batch.baseVersion ).to.be.null;
- } );
- it( 'should return null if all operations in batch have base version set to null', () => {
- const batch = new Batch();
- const opA = new Operation( null );
- const opB = new Operation( null );
- batch.addOperation( opA );
- batch.addOperation( opB );
- expect( batch.baseVersion ).to.equal( null );
- } );
- } );
- describe( 'is()', () => {
- let batch;
- beforeEach( () => {
- batch = new Batch();
- } );
- it( 'should return true for "batch"', () => {
- expect( batch.is( 'batch' ) ).to.be.true;
- } );
- it( 'should return false for incorrect values', () => {
- expect( batch.is( 'model' ) ).to.be.false;
- expect( batch.is( 'node' ) ).to.be.false;
- expect( batch.is( 'model:element' ) ).to.be.false;
- expect( batch.is( 'element', 'paragraph' ) ).to.be.false;
- expect( batch.is() ).to.be.false;
- } );
- } );
- } );
|