From 934f3233b93333f7c68277b2a3da0367b2cc53de Mon Sep 17 00:00:00 2001 From: Rikard Teodorsson <9367038+hej2010@users.noreply.github.com> Date: Fri, 17 Nov 2023 18:39:45 +0100 Subject: [PATCH] Update CloudCode.spec.js Signed-off-by: Rikard Teodorsson <9367038+hej2010@users.noreply.github.com> --- spec/CloudCode.spec.js | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/spec/CloudCode.spec.js b/spec/CloudCode.spec.js index 9bc205a130..7d19ae4665 100644 --- a/spec/CloudCode.spec.js +++ b/spec/CloudCode.spec.js @@ -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 @@ -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();