Skip to content

Commit

Permalink
Update CloudCode.spec.js
Browse files Browse the repository at this point in the history
Signed-off-by: Rikard Teodorsson <[email protected]>
  • Loading branch information
hej2010 authored Nov 17, 2023
1 parent 3d10062 commit 934f323
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,16 @@ describe('Cloud Code', () => {
count === 2 ? done() : fail();
});

it('should limit count query if limit is set', async () => {
const queries = [];
for (let i = 0; i < 10; i++) {
queries.push(new Parse.Object('Stuff').set('i', i).save());
}
await Promise.all(queries);
const count = await (new Parse.Query('Stuff').limit(5).count());
expect(count).toBe(5);
});

/**
* Verifies that an afterSave hook throwing an exception
* will not prevent a successful save response from being returned
Expand Down Expand Up @@ -2784,26 +2794,6 @@ describe('afterFind hooks', () => {
});
});

it('should limit count query if limit is set', async done => {
const hook = {
method: function (req) {
expect(req.count).toBe(true);
return Promise.resolve();
},
};
spyOn(hook, 'method').and.callThrough();
Parse.Cloud.beforeFind('Stuff', hook.method);

for (let i = 0; i < 10; i++) {
await new Parse.Object('Stuff').set('i', i).save(null, { useMasterKey: true });
}
new Parse.Query('Stuff').limit(5).count().then(count => {
expect(count).toBe(5);
expect(hook.method).toHaveBeenCalled();
done();
});
});

it('can set a pointer object in afterFind', async () => {
const obj = new Parse.Object('MyObject');
await obj.save();
Expand Down

0 comments on commit 934f323

Please sign in to comment.