|
|
@@ -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 );
|
|
|
|
|
|
@@ -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 );
|
|
|
|
|
|
@@ -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 ] );
|
|
|
} );
|
|
|
} );
|
|
|
|