File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -1298,6 +1298,52 @@ describe('miscellaneous', function() {
12981298 done ( ) ;
12991299 } ) ;
13001300 } )
1301+ } ) ;
1302+
1303+ it ( 'properly returns incremented values (#1554)' , ( done ) => {
1304+ let headers = {
1305+ 'Content-Type' : 'application/json' ,
1306+ 'X-Parse-Application-Id' : 'test' ,
1307+ 'X-Parse-REST-API-Key' : 'rest'
1308+ } ;
1309+ let requestOptions = {
1310+ headers : headers ,
1311+ url : 'http://localhost:8378/1/classes/AnObject' ,
1312+ json : true
1313+ } ;
1314+ let object = new Parse . Object ( 'AnObject' ) ; ;
1315+
1316+ function runIncrement ( amount ) {
1317+ let options = Object . assign ( { } , requestOptions , {
1318+ body : {
1319+ "key" : {
1320+ __op : 'Increment' ,
1321+ amount : amount
1322+ }
1323+ } ,
1324+ url : 'http://localhost:8378/1/classes/AnObject/' + object . id
1325+ } )
1326+ return new Promise ( ( resolve , reject ) => {
1327+ request . put ( options , ( err , res , body ) => {
1328+ if ( err ) {
1329+ reject ( err ) ;
1330+ } else {
1331+ resolve ( body ) ;
1332+ }
1333+ } ) ;
1334+ } )
1335+ }
1336+
1337+ object . save ( ) . then ( ( ) => {
1338+ return runIncrement ( 1 ) ;
1339+ } ) . then ( ( res ) => {
1340+ expect ( res . key ) . toBe ( 1 ) ;
1341+ return runIncrement ( - 1 ) ;
1342+ } ) . then ( ( res ) => {
1343+ console . log ( res ) ;
1344+ expect ( res . key ) . toBe ( 0 ) ;
1345+ done ( ) ;
1346+ } )
13011347 } )
13021348
13031349} ) ;
You can’t perform that action at this time.
0 commit comments