From 6512cffefc2eb5993a73e79ec1b97adc852a7a9e Mon Sep 17 00:00:00 2001 From: "Ben Scholzen (DASPRiD)" Date: Thu, 16 Jan 2025 14:41:02 +0100 Subject: [PATCH] test: update layout tests --- test/Layout.test.ts | 73 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/test/Layout.test.ts b/test/Layout.test.ts index 00e4f7f..ea0e2bc 100644 --- a/test/Layout.test.ts +++ b/test/Layout.test.ts @@ -250,7 +250,15 @@ describe('Layout', () => { describe('find', () => { it('should send a find call', async () => { - const expectedResponse = {data: [{recordId: '1', modId: '1'}], 'scriptResult': 'bar'}; + const expectedResponse = { + data: [{recordId: '1', modId: '1'}], + 'scriptResult': 'bar', + dataInfo: { + foundCount: 1, + returnedCount: 1, + totalRecordCount: 1, + }, + }; clientMock.request.withArgs('layouts/foo/_find', { method: 'POST', @@ -265,7 +273,14 @@ describe('Layout', () => { }); it('should send a find call with array query', async () => { - const expectedResponse = {data: [{recordId: '1', modId: '1'}]}; + const expectedResponse = { + data: [{recordId: '1', modId: '1'}], + dataInfo: { + foundCount: 1, + returnedCount: 1, + totalRecordCount: 1, + }, + }; clientMock.request.withArgs('layouts/foo/_find', { method: 'POST', @@ -280,7 +295,14 @@ describe('Layout', () => { }); it('should send a find call with offset and limit', async () => { - const expectedResponse = {data: [{recordId: '1', modId: '1'}]}; + const expectedResponse = { + data: [{recordId: '1', modId: '1'}], + dataInfo: { + foundCount: 1, + returnedCount: 1, + totalRecordCount: 1, + }, + }; clientMock.request.withArgs('layouts/foo/_find', { method: 'POST', @@ -296,7 +318,14 @@ describe('Layout', () => { }); it('should send a find call with single sort', async () => { - const expectedResponse = {data: [{recordId: '1', modId: '1'}]}; + const expectedResponse = { + data: [{recordId: '1', modId: '1'}], + dataInfo: { + foundCount: 1, + returnedCount: 1, + totalRecordCount: 1, + }, + }; clientMock.request.withArgs('layouts/foo/_find', { method: 'POST', @@ -311,7 +340,14 @@ describe('Layout', () => { }); it('should send a find call with array sort', async () => { - const expectedResponse = {data: [{recordId: '1', modId: '1'}]}; + const expectedResponse = { + data: [{recordId: '1', modId: '1'}], + dataInfo: { + foundCount: 1, + returnedCount: 1, + totalRecordCount: 1, + }, + }; clientMock.request.withArgs('layouts/foo/_find', { method: 'POST', @@ -326,7 +362,14 @@ describe('Layout', () => { }); it('should send a find call with portal ranges', async () => { - const expectedResponse = {data: [{recordId: '1', modId: '1'}]}; + const expectedResponse = { + data: [{recordId: '1', modId: '1'}], + dataInfo: { + foundCount: 1, + returnedCount: 1, + totalRecordCount: 1, + }, + }; clientMock.request.withArgs('layouts/foo/_find', { method: 'POST', @@ -342,7 +385,14 @@ describe('Layout', () => { }); it('should send a find call with empty portal ranges', async () => { - const expectedResponse = {data: [{recordId: '1', modId: '1'}]}; + const expectedResponse = { + data: [{recordId: '1', modId: '1'}], + dataInfo: { + foundCount: 1, + returnedCount: 1, + totalRecordCount: 1, + }, + }; clientMock.request.withArgs('layouts/foo/_find', { method: 'POST', @@ -376,7 +426,14 @@ describe('Layout', () => { }).rejects(new FileMakerError('401', 'Nothing found')); const response = await layout.find({foo: '=bar'}, {}, true); - expect(response).toEqual({data: []}); + expect(response).toEqual({ + data: [], + dataInfo: { + foundCount: 0, + returnedCount: 0, + totalRecordCount: 0, + }, + }); }); });