Adds ability to pass qs params to cloud code functions

This commit is contained in:
Florent Vilmart
2016-02-15 22:18:19 -05:00
parent e92176ce61
commit 8296d77f28
2 changed files with 34 additions and 2 deletions

View File

@@ -571,6 +571,35 @@ describe('miscellaneous', function() {
done();
});
});
it('test cloud function query parameters', (done) => {
Parse.Cloud.define('echoParams', (req, res) => {
res.success(req.params);
});
var headers = {
'Content-Type': 'application/json',
'X-Parse-Application-Id': 'test',
'X-Parse-Javascript-Key': 'test'
};
request.post({
headers: headers,
url: 'http://localhost:8378/1/functions/echoParams', //?option=1&other=2
qs: {
option: 1,
other: 2
},
body: '{"foo":"bar", "other": 1}'
}, (error, response, body) => {
expect(error).toBe(null);
var res = JSON.parse(body).result;
expect(res.option).toEqual('1');
// Make sure query string params override body params
expect(res.other).toEqual('2');
expect(res.foo).toEqual("bar");
delete Parse.Cloud.Functions['echoParams'];
done();
});
});
it('test cloud function parameter validation success', (done) => {
// Register a function with validation