@@ -868,6 +868,50 @@ describe('miscellaneous', function() {
868
868
});
869
869
});
870
870
871
+ it('should return the updated fields on PUT', (done) => {
872
+ let obj = new Parse.Object('GameScore');
873
+ obj.save({a:'hello', c: 1, d: ['1'], e:['1'], f:['1','2']}).then(( ) => {
874
+ var headers = {
875
+ 'Content-Type': 'application/json',
876
+ 'X-Parse-Application-Id': 'test',
877
+ 'X-Parse-REST-API-Key': 'rest',
878
+ 'X-Parse-Installation-Id': 'yolo'
879
+ };
880
+ request.put({
881
+ headers: headers,
882
+ url: 'http://localhost:8378/1/classes/GameScore/'+obj.id,
883
+ body: JSON.stringify({
884
+ a: 'b',
885
+ c: {"__op":"Increment","amount":2},
886
+ d: {"__op":"Add", objects: ['2']},
887
+ e: {"__op":"AddUnique", objects: ['1', '2']},
888
+ f: {"__op":"Remove", objects: ['2']},
889
+ selfThing: {"__type":"Pointer","className":"GameScore","objectId":obj.id},
890
+ })
891
+ }, (error, response, body) => {
892
+ body = JSON.parse(body);
893
+ expect(body.a).toBeUndefined();
894
+ expect(body.c).toEqual(3); // 2+1
895
+ expect(body.d.length).toBe(2);
896
+ expect(body.d.indexOf('1') > -1).toBe(true);
897
+ expect(body.d.indexOf('2') > -1).toBe(true);
898
+ expect(body.e.length).toBe(2);
899
+ expect(body.e.indexOf('1') > -1).toBe(true);
900
+ expect(body.e.indexOf('2') > -1).toBe(true);
901
+ expect(body.f.length).toBe(1);
902
+ expect(body.f.indexOf('1') > -1).toBe(true);
903
+ // return nothing on other self
904
+ expect(body.selfThing).toBeUndefined();
905
+ // updatedAt is always set
906
+ expect(body.updatedAt).not.toBeUndefined();
907
+ done();
908
+ });
909
+ }).fail((err) => {
910
+ fail('Should not fail');
911
+ done();
912
+ })
913
+ })
914
+
871
915
it('test cloud function error handling', (done) => {
872
916
// Register a function which will fail
873
917
Parse.Cloud.define('willFail', (req, res) => {
0 commit comments