Skip to content

Commit 6855bd9

Browse files
flovilmartdplewis
authored andcommitted
modernize cloud code (#642)
* modernize cloud code * de-duplicate test names * improves test
1 parent 81e8c44 commit 6855bd9

File tree

4 files changed

+138
-41
lines changed

4 files changed

+138
-41
lines changed

integration/cloud/main.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
/* global Parse */
2-
Parse.Cloud.define("bar", function(request, response) {
2+
Parse.Cloud.define("bar", function(request) {
33
if (request.params.key2 === "value1") {
4-
response.success('Foo');
4+
return 'Foo';
55
} else {
6-
response.error("bad stuff happened");
6+
throw "bad stuff happened";
77
}
88
});
99

10-
Parse.Cloud.job('CloudJob1', function(request, response) {
11-
response.success({
10+
Parse.Cloud.job('CloudJob1', function() {
11+
return {
1212
status: 'cloud job completed'
13-
});
13+
};
1414
});
1515

16-
Parse.Cloud.job('CloudJob2', function(request, response) {
17-
setTimeout(function() {
18-
response.success({
19-
status: 'cloud job completed'
20-
})
21-
}, 3000);
16+
Parse.Cloud.job('CloudJob2', function() {
17+
return new Promise((resolve) => {
18+
setTimeout(function() {
19+
resolve({
20+
status: 'cloud job completed'
21+
})
22+
}, 3000);
23+
});
2224
});
2325

24-
Parse.Cloud.job('CloudJobFailing', function(request, response) {
25-
response.error('cloud job failed');
26+
Parse.Cloud.job('CloudJobFailing', function() {
27+
throw 'cloud job failed';
2628
});

integration/test/ParseGeoPointTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('Geo Point', () => {
251251
});
252252
});
253253

254-
it('can measure distance within km - mid peninsula', (done) => {
254+
it('can measure distance within miles - mid peninsula', (done) => {
255255
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
256256
const query = new Parse.Query(TestPoint);
257257
query.withinMiles('location', sfo, 10.0);
@@ -406,7 +406,7 @@ describe('Geo Point', () => {
406406
});
407407
});
408408

409-
it('can measure distance within km unsorted - mid peninsula', (done) => {
409+
it('can measure distance within miles unsorted - mid peninsula', (done) => {
410410
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
411411
const query = new Parse.Query(TestPoint);
412412
query.withinMiles('location', sfo, 10.0, false);

integration/test/ParseQueryTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('Parse Query', () => {
4646
return query.find();
4747
}).then((results) => {
4848
assert.equal(results.length, 1);
49-
assert.equal(results[0].get('foo'), 'baz');
49+
assert.equal(['baz', 'qux'].includes(results[0].get('foo')), true);
5050
done();
5151
}).catch(done.fail);
5252
});

package-lock.json

Lines changed: 119 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)