Skip to content

Commit

Permalink
Merge pull request #289 from flovilmart/handle-server-set-delete-op
Browse files Browse the repository at this point in the history
Adds ability to interpolate delete operations
  • Loading branch information
andrewimm committed Jun 6, 2016
2 parents ef2b483 + d3ef256 commit 117c091
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ParseObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ export default class ParseObject {
changes[attr] = new ParseACL(response[attr]);
} else if (attr !== 'objectId') {
changes[attr] = decode(response[attr]);
if (changes[attr] instanceof UnsetOp) {
changes[attr] = undefined;
}
}
}
if (changes.createdAt && !changes.updatedAt) {
Expand Down
15 changes: 15 additions & 0 deletions src/__tests__/ParseObject-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,21 @@ describe('ParseObject', () => {
done();
});
}));

it('interpolates delete operations', asyncHelper((done) => {
CoreManager.getRESTController()._setXHR(
mockXHR([{
status: 200,
response: { objectId: 'newattributes', deletedKey: {__op: 'Delete'} }
}])
);
var o = new ParseObject('Item');
o.save({ key: 'value', deletedKey: 'keyToDelete' }).then(() => {
expect(o.get('key')).toBe('value');
expect(o.get('deletedKey')).toBeUndefined();
done();
});
}));

it('can make changes while in the process of a save', asyncHelper((done) => {
var xhr = {
Expand Down

0 comments on commit 117c091

Please sign in to comment.