From f8c75ed4b9b56a39c2984437dd61f1d50ae80690 Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Thu, 11 Jan 2024 15:32:54 +0530 Subject: [PATCH] Added pagination API test cases in assets and entries. --- test/api/asset-query.spec.ts | 18 ++++++++++++++++++ test/api/entries.spec.ts | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/test/api/asset-query.spec.ts b/test/api/asset-query.spec.ts index ace3acc8..32427827 100644 --- a/test/api/asset-query.spec.ts +++ b/test/api/asset-query.spec.ts @@ -76,6 +76,24 @@ describe('AssetQuery API tests', () => { expect(result.assets[0].created_by).toBeDefined(); expect(result.assets[0].updated_by).toBeDefined(); }); + it('should check for limit', async () => { + const query = makeAssetQuery(); + const result = await query.limit(2).find(); + expect(query._queryParams).toEqual({limit: 2}); + expect(result.assets[0].uid).toBeDefined(); + expect(result.assets[0].content_type).toBeDefined(); + expect(result.assets[0].created_by).toBeDefined(); + expect(result.assets[0].updated_by).toBeDefined(); + }); + it.only('should check for skip', async () => { + const query = makeAssetQuery(); + const result = await query.skip(2).find(); + expect(query._queryParams).toEqual({skip: 2}); + expect(result.assets[0].uid).toBeDefined(); + expect(result.assets[0].content_type).toBeDefined(); + expect(result.assets[0].created_by).toBeDefined(); + expect(result.assets[0].updated_by).toBeDefined(); + }); }); function makeAssetQuery(): AssetQuery { const asset = stack.Asset(); diff --git a/test/api/entries.spec.ts b/test/api/entries.spec.ts index 6ce55115..eac3e0a1 100644 --- a/test/api/entries.spec.ts +++ b/test/api/entries.spec.ts @@ -56,6 +56,23 @@ describe('Entries API test cases', () => { expect(result.entries[0].uid).toBeDefined(); expect(result.entries[0].author).toBeDefined(); }); + it('should check for limit', async () => { + const query = makeEntries('blog_post'); + const result = await query.limit(2).find(); + expect(query._queryParams).toEqual({limit: 2}); + expect(result.entries[0]._version).toBeDefined(); + expect(result.entries[0].locale).toEqual('en-us'); + expect(result.entries[0].uid).toBeDefined(); + expect(result.entries[0].title).toBeDefined(); + }); + it.only('should check for skip', async () => { + const query = makeEntries('blog_post'); + const result = await query.skip(2).find(); + expect(query._queryParams).toEqual({skip: 2}); + expect(result.entries[0]._version).toBeDefined(); + expect(result.entries[0].uid).toBeDefined(); + expect(result.entries[0].title).toBeDefined(); + }); }); function makeEntries(contentTypeUid = ''): Entries { const entries = stack.ContentType(contentTypeUid).Entry();