Skip to content

Commit 09fcde2

Browse files
dblythyEmpiDev
authored andcommitted
wip
1 parent ec37789 commit 09fcde2

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

spec/CloudCode.spec.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ describe('Cloud Code', () => {
206206
Parse.Cloud.beforeFind('beforeFind', () => {
207207
return new Parse.Object('TestObject', { foo: 'bar' });
208208
});
209-
Parse.Cloud.afterFind('beforeFind', () => {
210-
throw 'afterFind should not run';
209+
Parse.Cloud.afterFind('beforeFind', req => {
210+
expect(req.objects).toBeDefined();
211+
expect(req.objects[0].get('foo')).toBe('bar');
211212
});
212213
const newObj = await new Parse.Query('beforeFind').first();
213214
expect(newObj.className).toBe('TestObject');
@@ -219,8 +220,9 @@ describe('Cloud Code', () => {
219220
Parse.Cloud.beforeFind('beforeFind', () => {
220221
return [new Parse.Object('TestObject', { foo: 'bar' })];
221222
});
222-
Parse.Cloud.afterFind('beforeFind', () => {
223-
throw 'afterFind should not run';
223+
Parse.Cloud.afterFind('beforeFind', req => {
224+
expect(req.objects).toBeDefined();
225+
expect(req.objects[0].get('foo')).toBe('bar');
224226
});
225227
const newObj = await new Parse.Query('beforeFind').first();
226228
expect(newObj.className).toBe('TestObject');
@@ -232,8 +234,9 @@ describe('Cloud Code', () => {
232234
Parse.Cloud.beforeFind('beforeFind', () => {
233235
return [new Parse.Object('TestObject', { foo: 'bar' })];
234236
});
235-
Parse.Cloud.afterFind('beforeFind', () => {
236-
throw 'afterFind should not run';
237+
Parse.Cloud.afterFind('beforeFind', req => {
238+
expect(req.objects).toBeDefined();
239+
expect(req.objects[0].get('foo')).toBe('bar');
237240
});
238241
const newObj = await new Parse.Query('beforeFind').get('objId');
239242
expect(newObj.className).toBe('TestObject');
@@ -245,8 +248,8 @@ describe('Cloud Code', () => {
245248
Parse.Cloud.beforeFind('beforeFind', () => {
246249
return [];
247250
});
248-
Parse.Cloud.afterFind('beforeFind', () => {
249-
throw 'afterFind should not run';
251+
Parse.Cloud.afterFind('beforeFind', req => {
252+
expect(req.objects.length).toBe(0);
250253
});
251254
const obj = new Parse.Object('beforeFind');
252255
await obj.save();

src/triggers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,10 @@ export function maybeRunAfterFindTrigger(
471471
);
472472
request.objects = objects.map(object => {
473473
//setting the class name to transform into parse object
474+
object.className = className;
474475
if (object instanceof Parse.Object) {
475476
return object;
476477
}
477-
object.className = className;
478478
return Parse.Object.fromJSON(object);
479479
});
480480
return Promise.resolve()

0 commit comments

Comments
 (0)