Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"jasmineExplorer.config": "jasmine.json",
"jasmineExplorer.env": {
"TESTING": "1"
}
},
"flow.useNPMPackagedFlow": true,
"javascript.validate.enable": false
}
19 changes: 19 additions & 0 deletions integration/cloud/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,22 @@ Parse.Cloud.job('CloudJob2', function() {
Parse.Cloud.job('CloudJobFailing', function() {
throw 'cloud job failed';
});

//ugly patch. Should not stay here, but I don't know how to test changes in Cloud Code otherwise
//parse-server uses the published parse SDK version, but we want to test the patched version via cloud code
const PatchedParse = require('../../node').Parse;
//FunctionsRouter.js 104 calls Parse._encode directly, so it must be patched.
Parse._encode = PatchedParse._encode;
//Parse.Object calls encode, so it must be patched.
Parse.Object = PatchedParse.Object;

Parse.Cloud.define('getUnsavedObject', function(){
const parent = new Parse.Object("Unsaved");
const child = new Parse.Object("secondUnsaved");
const childOfChild = new Parse.Object("thirdUnsaved");
child.set("foz", "baz");
child.set("child", childOfChild);
parent.set("foo", "bar");
parent.set("child", child);
return parent;
});
11 changes: 11 additions & 0 deletions integration/test/ParseCloudTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,15 @@ describe('Parse Cloud', () => {
done();
});
});

it('should transfer unsaved object as full JSON', (done) => {
Parse.Cloud.run('getUnsavedObject').then((result) => {
expect(result).toBeInstanceOf(Parse.Object);
expect(result.get('foo')).toEqual('bar');
expect(result.get('child')).toBeInstanceOf(Parse.Object);
expect(result.get('child').get('child')).toBeInstanceOf(Parse.Object);
expect(result.get('child').get('foz')).toEqual('baz');
done();
}).catch(done.fail);
});
});
Loading