Skip to content

Commit

Permalink
Tests: Upgraded tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Sep 24, 2020
1 parent 6901e2c commit bdd7db9
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions packages/ckeditor5-engine/tests/model/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ describe( 'History', () => {

describe( 'getOperations', () => {
it( 'should return only operations from given base version', () => {
history.addOperation( ( new Operation( 0 ) ) );
history.addOperation( ( new Operation( 1 ) ) );
history.addOperation( ( new Operation( 2 ) ) );
history.addOperation( new Operation( 0 ) );
history.addOperation( new Operation( 1 ) );
history.addOperation( new Operation( 2 ) );

const ops = history.getOperations( 1 );

Expand All @@ -95,9 +95,9 @@ describe( 'History', () => {
} );

it( 'should return only operations up to given base version', () => {
history.addOperation( ( new Operation( 0 ) ) );
history.addOperation( ( new Operation( 1 ) ) );
history.addOperation( ( new Operation( 2 ) ) );
history.addOperation( new Operation( 0 ) );
history.addOperation( new Operation( 1 ) );
history.addOperation( new Operation( 2 ) );

const ops = history.getOperations( 1, 2 );

Expand All @@ -106,31 +106,31 @@ describe( 'History', () => {
} );

it( 'should return empty array if no operations match', () => {
history.addOperation( ( new Operation( 0 ) ) );
history.addOperation( ( new Operation( 1 ) ) );
history.addOperation( new Operation( 0 ) );
history.addOperation( new Operation( 1 ) );

expect( history.getOperations( 20 ).length ).to.equal( 0 );
expect( history.getOperations( -3, 0 ).length ).to.equal( 0 );
} );

it( 'should return correct values if history holds operations with negative base version', () => {
history.addOperation( ( new Operation( -2 ) ) );
history.addOperation( ( new Operation( -1 ) ) );
history.addOperation( ( new Operation( 0 ) ) );
history.addOperation( ( new Operation( 1 ) ) );
history.addOperation( ( new Operation( 2 ) ) );
history.addOperation( new Operation( -2 ) );
history.addOperation( new Operation( -1 ) );
history.addOperation( new Operation( 0 ) );
history.addOperation( new Operation( 1 ) );
history.addOperation( new Operation( 2 ) );

expect( history.getOperations( -1, 2 ).length ).to.equal( 3 ); // -1, 0, 1.
expect( history.getOperations( -1, 2 ).map( op => op.baseVersion ) ).to.deep.equal( [ -1, 0, 1 ] );
} );

it( 'should return correct values if history holds operations with base versions that differ by more than one', () => {
history.addOperation( ( new Operation( 0 ) ) );
history.addOperation( ( new Operation( 4 ) ) );
history.addOperation( ( new Operation( 6 ) ) );
history.addOperation( ( new Operation( 9 ) ) );
history.addOperation( ( new Operation( 13 ) ) );
history.addOperation( new Operation( 0 ) );
history.addOperation( new Operation( 4 ) );
history.addOperation( new Operation( 6 ) );
history.addOperation( new Operation( 9 ) );
history.addOperation( new Operation( 13 ) );

expect( history.getOperations( 2, 11 ).length ).to.equal( 3 ); // 4, 6, 9.
expect( history.getOperations( 2, 11 ).map( op => op.baseVersion ) ).to.deep.equal( [ 4, 6, 9 ] );
} );
} );

Expand Down

0 comments on commit bdd7db9

Please sign in to comment.