diff --git a/ExportManager.js b/ExportManager.js index 509bc49..7352549 100644 --- a/ExportManager.js +++ b/ExportManager.js @@ -594,7 +594,7 @@ class ExportManager if (this.simulateDeletedPct && this.since) { let cnt = Math.round(count/100 * this.simulateDeletedPct); - deletedArr.push({ + cnt && deletedArr.push({ type: row.fhir_type, count: cnt, url: lib.buildUrlPath( diff --git a/tests/bulk_data.test.js b/tests/bulk_data.test.js index a009d5e..aee531c 100644 --- a/tests/bulk_data.test.js +++ b/tests/bulk_data.test.js @@ -124,6 +124,7 @@ class Client * @param {object} [options.headers = {}] * @param {boolean} [options.secure = false] * @param {string} [options.fileError] + * @param {number} [options.del] */ async kickOff(options = {}) { @@ -134,7 +135,8 @@ class Client err : options.simulatedError || "", extended: !!options.extended, secure : !!options.secure, - fileError: options.fileError + fileError: options.fileError, + del: options.del }; if (options.resourcesPerFile) { @@ -1592,6 +1594,19 @@ describe("File Downloading", function() { } } }); + + it("Retrieval of referenced files on an open endpoint with deletions", async () => { + const client = new Client(); + await client.kickOff({ _type: "Device", _since: "2010-01-01T12:00:00Z", del: 10 }); + const status = await client.checkStatus(); + + const deleted = status.body.deleted + assert(Array.isArray(deleted)) + + await Promise.all( + deleted.map(file => client.downloadFile(file.url)) + ) + }); it("Retrieval of referenced files on protected endpoint", async () => { const { access_token } = await lib.authorize();