@@ -12,6 +12,30 @@ describe("JSONPatchQueue instance", function () {
1212 expect ( queue . remoteVersion ) . toEqual ( 0 ) ;
1313 } ) ;
1414
15+ describe ( 'when reset' , function ( ) {
16+ it ( 'should set remote version to value given' , function ( ) {
17+ var queue = new JSONPatchQueue ( [ "/local" , "/remote" ] , function ( ) { } ) ;
18+ queue . reset ( { } , { local : 1 , remote : 2 } ) ;
19+ expect ( queue . remoteVersion ) . toEqual ( 2 ) ;
20+ } ) ;
21+ it ( 'should set remote version to value given even with complex version path' , function ( ) {
22+ var queue = new JSONPatchQueue ( [ "/v/local" , "/v/remote" ] , function ( ) { } ) ;
23+ queue . reset ( { } , { v : { local : 1 , remote : 2 } } ) ;
24+ expect ( queue . remoteVersion ) . toEqual ( 2 ) ;
25+ } ) ;
26+ it ( 'should apply big replace patch to obj' , function ( ) {
27+ var appliedPatch ;
28+ var queue = new JSONPatchQueue ( [ "/local" , "/remote" ] , function apply ( obj , patches ) {
29+ appliedPatch = patches ;
30+ } ) ;
31+ var newState = { local : 1 , remote : 2 , name : 'newname' } ;
32+
33+ queue . reset ( { } , newState ) ;
34+
35+ expect ( appliedPatch ) . toEqual ( [ { op : 'replace' , path : '' , value : newState } ] ) ;
36+ } ) ;
37+ } ) ;
38+
1539 describe ( "when receives a Versioned JSON Patch" , function ( ) {
1640 var queue , applyPatch ;
1741 beforeEach ( function ( ) {
0 commit comments