diff --git a/lib/repack-result.js b/lib/repack-result.js index 3f06a01..dc2eaff 100644 --- a/lib/repack-result.js +++ b/lib/repack-result.js @@ -1,6 +1,5 @@ const { logger } = require('@vtfk/logger') const hasData = require('./has-data') -const HTTPError = require('./http-error') const unwantedProperties = [ 'ErrorDetails', @@ -53,8 +52,7 @@ module.exports = (result = {}, options) => { } if (output.length === 1 && !hasData(output[0])) { - logger('error', ['repack-result', 404, 'Not found']) - throw new HTTPError(404, 'Not found') + return [] } return output diff --git a/test/repack-result.test.js b/test/repack-result.test.js index bb1c968..ff1994b 100644 --- a/test/repack-result.test.js +++ b/test/repack-result.test.js @@ -187,6 +187,15 @@ const resultCreateCaseWithErrorMessage = repackResult({ TotalPageCount: 1 }) +const resultPrivatePersonWithEmptyResponse = repackResult({ + PrivatePersons: [], + TotalPageCount: 0, + TotalCount: 0, + Successful: true, + ErrorMessage: null, + ErrorDetails: null +}) + test('PrivatePerson result is Array', () => { expect(Array.isArray(resultPrivatePerson)).toBe(true) }) @@ -199,6 +208,15 @@ test('PrivatePerson results one item has a "Recno" property', () => { expect(resultPrivatePerson[0].Recno).toBe(123456) }) +test('PrivatePerson with empty response is array', () => { + expect(Array.isArray(resultPrivatePersonWithEmptyResponse)).toBe(true) +}) + +test('PrivatePerson with empty response is empty array', () => { + console.log(resultPrivatePersonWithEmptyResponse) + expect(resultPrivatePersonWithEmptyResponse.length).toBe(0) +}) + test('CreateCase result is Array', () => { expect(Array.isArray(resultCreateCase)).toBe(true) })