@@ -956,15 +956,15 @@ describe('Automerge', () => {
956956 doc1 . free ( )
957957 } )
958958
959- it . skip ( 'should capture local increment ops' , ( ) => {
959+ it ( 'should capture local increment ops' , ( ) => {
960960 let doc1 = create ( 'aaaa' )
961961 doc1 . enablePatches ( true )
962962 doc1 . put ( '_root' , 'counter' , 2 , 'counter' )
963963 doc1 . increment ( '_root' , 'counter' , 4 )
964964
965965 assert . deepEqual ( doc1 . popPatches ( ) , [
966966 { action : 'put' , obj : '_root' , key : 'counter' , value : 2 , datatype : 'counter' , conflict : false } ,
967- { action : 'put ' , obj : '_root' , key : 'counter' , value : 6 , datatype : 'counter' , conflict : false } ,
967+ { action : 'increment ' , obj : '_root' , key : 'counter' , value : 4 } ,
968968 ] )
969969 doc1 . free ( )
970970 } )
@@ -986,23 +986,41 @@ describe('Automerge', () => {
986986 doc1 . free ( )
987987 } )
988988
989- it . skip ( 'should support counters in a map' , ( ) => {
989+ it ( 'should support counters in a map' , ( ) => {
990990 let doc1 = create ( 'aaaa' ) , doc2 = create ( 'bbbb' )
991991 doc2 . enablePatches ( true )
992992 doc1 . put ( '_root' , 'starlings' , 2 , 'counter' )
993993 doc2 . loadIncremental ( doc1 . saveIncremental ( ) )
994994 doc1 . increment ( '_root' , 'starlings' , 1 )
995- doc1 . dump ( )
996995 doc2 . loadIncremental ( doc1 . saveIncremental ( ) )
997996 assert . deepEqual ( doc2 . get ( '_root' , 'starlings' ) , [ 'counter' , 3 ] )
998997 assert . deepEqual ( doc2 . popPatches ( ) , [
999998 { action : 'put' , obj : '_root' , key : 'starlings' , value : 2 , datatype : 'counter' , conflict : false } ,
1000- { action : 'put ' , obj : '_root' , key : 'starlings' , value : 3 , datatype : 'counter' , conflict : false }
999+ { action : 'increment ' , obj : '_root' , key : 'starlings' , value : 1 }
10011000 ] )
10021001 doc1 . free ( ) ; doc2 . free ( )
10031002 } )
10041003
1005- it ( 'should support counters in a list' ) // TODO
1004+ it ( 'should support counters in a list' , ( ) => {
1005+ let doc1 = create ( 'aaaa' ) , doc2 = create ( 'bbbb' )
1006+ doc2 . enablePatches ( true )
1007+ const list = doc1 . putObject ( '_root' , 'list' , [ ] )
1008+ doc2 . loadIncremental ( doc1 . saveIncremental ( ) )
1009+ doc1 . insert ( list , 0 , 1 , 'counter' )
1010+ doc2 . loadIncremental ( doc1 . saveIncremental ( ) )
1011+ doc1 . increment ( list , 0 , 2 )
1012+ doc2 . loadIncremental ( doc1 . saveIncremental ( ) )
1013+ doc1 . increment ( list , 0 , - 5 )
1014+ doc2 . loadIncremental ( doc1 . saveIncremental ( ) )
1015+
1016+ assert . deepEqual ( doc2 . popPatches ( ) , [
1017+ { action : 'put' , obj : '_root' , key : 'list' , value : list , datatype : 'list' , conflict : false } ,
1018+ { action : 'insert' , obj : list , key : 0 , value : 1 , datatype : 'counter' } ,
1019+ { action : 'increment' , obj : list , key : 0 , value : 2 } ,
1020+ { action : 'increment' , obj : list , key : 0 , value : - 5 } ,
1021+ ] )
1022+ doc1 . free ( ) ; doc2 . free ( )
1023+ } )
10061024
10071025 it ( 'should delete a counter from a map' ) // TODO
10081026 } )
0 commit comments