From c768664ab8b731e6a7002767b32343f771c67768 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 20 Sep 2023 14:32:02 -0500 Subject: [PATCH] lint --- .../tests/UploadingJobsDisplay.test.js | 8 ++-- src/routes/ViewAllLogs/ViewAllLogs.test.js | 4 +- src/utils/tests/compositeJobStatus.test.js | 40 ++++++++-------- src/utils/tests/multipartUpload.test.js | 48 +++++++++---------- src/utils/tests/upload.test.js | 4 +- 5 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/components/UploadingJobsDisplay/tests/UploadingJobsDisplay.test.js b/src/components/UploadingJobsDisplay/tests/UploadingJobsDisplay.test.js index 6cc73dd8a..4e1cad1c7 100644 --- a/src/components/UploadingJobsDisplay/tests/UploadingJobsDisplay.test.js +++ b/src/components/UploadingJobsDisplay/tests/UploadingJobsDisplay.test.js @@ -40,8 +40,8 @@ const kyMock = () => ({ }); const mockMultipart = ( - uploadDefId = 'test', - files = [], + uploadDefId = 'test', // eslint-disable-line + files = [], // eslint-disable-line ky = kyMock, errorHandler = jest.fn(), progressHandler = jest.fn(), @@ -52,13 +52,13 @@ const mockMultipart = ( try { ky.post(); progressHandler({ current: 30, total: 100 }); - successHandler(successMock, mockKey, true) + successHandler(); } catch (error) { errorHandler(error); } } }; -} +}; jest.mock('../../../utils/multipartUpload', () => ({ ...jest.requireActual('../../../utils/multipartUpload'), diff --git a/src/routes/ViewAllLogs/ViewAllLogs.test.js b/src/routes/ViewAllLogs/ViewAllLogs.test.js index 018d000fa..aee92ee33 100644 --- a/src/routes/ViewAllLogs/ViewAllLogs.test.js +++ b/src/routes/ViewAllLogs/ViewAllLogs.test.js @@ -609,7 +609,7 @@ describe('ViewAllLogs - getLogsPath function', () => { }); it('returns undefined path if splitStatus has not responded yet', () => { - expect(getLogsPath(null, null, { query: {} }, null, { resources: { splitStatus: { hasLoaded: false }} })).not.toBeDefined(); + expect(getLogsPath(null, null, { query: {} }, null, { resources: { splitStatus: { hasLoaded: false } } })).not.toBeDefined(); }); }); @@ -619,7 +619,7 @@ describe('ViewAllLogs - getLogsQuery function', () => { }); it('returns expected query if multipart functionality is not available', () => { - expect(getLogsQuery(null, null, { query: {} }, null, { resources: { splitStatus: { hasLoaded: true, records: [{splitStatus: false}] } }})).not.toHaveProperty('subordinationTypeNotAny', ['COMPOSITE_PARENT']); + expect(getLogsQuery(null, null, { query: {} }, null, { resources: { splitStatus: { hasLoaded: true, records: [{ splitStatus: false }] } } })).not.toHaveProperty('subordinationTypeNotAny', ['COMPOSITE_PARENT']); }); it('returns empty query if multipart check has not responded yet', () => { diff --git a/src/utils/tests/compositeJobStatus.test.js b/src/utils/tests/compositeJobStatus.test.js index 7cb71be7e..c97e4730c 100644 --- a/src/utils/tests/compositeJobStatus.test.js +++ b/src/utils/tests/compositeJobStatus.test.js @@ -10,31 +10,31 @@ import { const mockJob = { compositeDetails: { - fileUploadedState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10}, - parsingInProgressState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10}, - parsingFinishedState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10}, - processingInProgressState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10}, - processingFinishedState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10}, - commitInProgressState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10}, - errorState:{ totalRecordsCount: 50, currentlyProcessedCount: 10, chunksCount: 30}, - discardedState:{ totalRecordsCount: 50, currentlyProcessedCount: 10, chunksCount: 30}, - cancelledState:{ totalRecordsCount: 50, currentlyProcessedCount: 10, chunksCount: 30}, - committedState:{ totalRecordsCount: 4, currentlyProcessedCount: 2, chunksCount: 50} + fileUploadedState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10 }, + parsingInProgressState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10 }, + parsingFinishedState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10 }, + processingInProgressState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10 }, + processingFinishedState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10 }, + commitInProgressState:{ totalRecordsCount: 100, currentlyProcessedCount: 33, chunksCount: 10 }, + errorState:{ totalRecordsCount: 50, currentlyProcessedCount: 10, chunksCount: 30 }, + discardedState:{ totalRecordsCount: 50, currentlyProcessedCount: 10, chunksCount: 30 }, + cancelledState:{ totalRecordsCount: 50, currentlyProcessedCount: 10, chunksCount: 30 }, + committedState:{ totalRecordsCount: 4, currentlyProcessedCount: 2, chunksCount: 50 } } }; const mockNaNJob = { compositeDetails: { - fileUploadedState:{ chunksCount: 10}, - parsingInProgressState:{ chunksCount: 10}, - parsingFinishedState:{ chunksCount: 10}, - processingInProgressState:{ chunksCount: 10}, - processingFinishedState:{ chunksCount: 10}, - commitInProgressState:{ chunksCount: 10}, - errorState:{ chunksCount: 30}, - discardedState:{ chunksCount: 30}, - cancelledState:{ chunksCount: 30}, - committedState:{ chunksCount: 50} + fileUploadedState:{ chunksCount: 10 }, + parsingInProgressState:{ chunksCount: 10 }, + parsingFinishedState:{ chunksCount: 10 }, + processingInProgressState:{ chunksCount: 10 }, + processingFinishedState:{ chunksCount: 10 }, + commitInProgressState:{ chunksCount: 10 }, + errorState:{ chunksCount: 30 }, + discardedState:{ chunksCount: 30 }, + cancelledState:{ chunksCount: 30 }, + committedState:{ chunksCount: 50 } } }; diff --git a/src/utils/tests/multipartUpload.test.js b/src/utils/tests/multipartUpload.test.js index a506bbc93..b47458577 100644 --- a/src/utils/tests/multipartUpload.test.js +++ b/src/utils/tests/multipartUpload.test.js @@ -15,32 +15,32 @@ import { trimLeadNumbers, } from '../multipartUpload'; -const testId = 'testId' +const testId = 'testId'; const responseMock = jest.fn(); const getMock = jest.fn((url) => { if (url === initMPUploadEndpoint) { - return { - json: () => { return Promise.resolve({ url: 'testUrl', uploadId: testId, key: 'testKey' })} - } + return { + json: () => { return Promise.resolve({ url: 'testUrl', uploadId: testId, key: 'testKey' }); } + }; } if (url === requestPartUploadURL) { - return { - json: () => { return Promise.resolve({ url: 'testSubsequentUrl', key: 'testSubsequentKey' })} - } + return { + json: () => { return Promise.resolve({ url: 'testSubsequentUrl', key: 'testSubsequentKey' }); } + }; } if (url.startsWith(getFinishUploadEndpoint(testId, 'undefined'))) { - return { - json: () => { return Promise.resolve({ ok: true })} - } + return { + json: () => { return Promise.resolve({ ok: true }); } + }; } if (url.startsWith(cancelMultipartJobEndpoint(testId))) { return { - json: () => { return Promise.resolve({ ok: true })} - } -} + json: () => { return Promise.resolve({ ok: true }); } + }; + } return { json: () => { return Promise.resolve(responseMock()); - }}; + } }; }); const kyMock = { @@ -128,10 +128,10 @@ describe('MultipartUploader class', () => { const successHandler = jest.fn(); const createMultipartUploader = (size = 31457280) => new MultipartUploader( testId, - {file1: { + { file1: { file: getFileOfSize(size), - size: size - }}, + size + } }, kyMock, errorHandler, progressHandler, @@ -154,13 +154,13 @@ describe('MultipartUploader class', () => { uploader = createMultipartUploader(); uploader.init(); await waitFor(() => expect(mockXHR.addEventListener).toHaveBeenCalled()); - let progress = mockXHR.upload.addEventListener.mock.calls[0][1]; + const progress = mockXHR.upload.addEventListener.mock.calls[0][1]; progress({ loaded: 12, total: 100 }); expect(progressHandler).toHaveBeenCalled(); mockXHR.status = 200; progress({ loaded: 100, total: 100 }); expect(progressHandler).toHaveBeenCalledTimes(2); - let readystatechange = mockXHR.addEventListener.mock.calls[0][1]; + const readystatechange = mockXHR.addEventListener.mock.calls[0][1]; readystatechange(); await waitFor(() => expect(successHandler).toBeCalled()); expect(mockXHR.open).toHaveBeenCalled(); @@ -177,7 +177,7 @@ describe('MultipartUploader class', () => { mockXHR.status = 200; readystatechange(); await waitFor(() => expect(mockXHR.send).toHaveBeenCalledTimes(2)); - readystatechange = mockXHR.addEventListener.mock.calls[2][1] + readystatechange = mockXHR.addEventListener.mock.calls[2][1]; readystatechange(); await waitFor(() => expect(successHandler).toBeCalled()); await waitFor(() => expect(errorHandler).toHaveBeenCalledTimes(0)); @@ -192,10 +192,10 @@ describe('MultipartUploader class', () => { mockXHR.status = 200; readystatechange(); mockXHR.status = 0; - await waitFor(() => expect(mockXHR.open).toHaveBeenCalledTimes(2)) + await waitFor(() => expect(mockXHR.open).toHaveBeenCalledTimes(2)); readystatechange = mockXHR.addEventListener.mock.calls[2][1]; uploader.abort(); - let abort = mockXHR.upload.addEventListener.mock.calls[3][1]; + const abort = mockXHR.upload.addEventListener.mock.calls[3][1]; abort(); readystatechange(); expect(uploader.abortSignal).toBe(true); @@ -212,8 +212,8 @@ describe('MultipartUploader class', () => { mockXHR.status = 200; readystatechange(); mockXHR.status = 500; - mockXHR.responseText = JSON.stringify({ message: 'there was a problem!' }) - await waitFor(() => expect(mockXHR.open).toHaveBeenCalledTimes(2)) + mockXHR.responseText = JSON.stringify({ message: 'there was a problem!' }); + await waitFor(() => expect(mockXHR.open).toHaveBeenCalledTimes(2)); readystatechange = mockXHR.addEventListener.mock.calls[2][1]; readystatechange(); expect(uploader.abortSignal).toBe(false); diff --git a/src/utils/tests/upload.test.js b/src/utils/tests/upload.test.js index 98ca4f455..0b2acaffc 100644 --- a/src/utils/tests/upload.test.js +++ b/src/utils/tests/upload.test.js @@ -205,12 +205,12 @@ describe('getLatestUploadDefinition function', () => { describe('mapFilesToUI', () => { it('Given an undefined status value, and canUseObjectStorage: true, sets status to "UPLOADING-CANCELLABLE"', () => { const files = mapFilesToUI([{ name: 'testfile', lastModified: '202021122' }], true); - expect(files['testfile202021122']).toHaveProperty('status', 'UPLOADING-CANCELLABLE'); + expect(files.testfile202021122).toHaveProperty('status', 'UPLOADING-CANCELLABLE'); }); it('Given an undefined status value, and canUseObjectStorage: false, sets status to "UPLOADING"', () => { const files = mapFilesToUI([{ name: 'testfile', lastModified: '202021122' }], false); - expect(files['testfile202021122']).toHaveProperty('status', 'UPLOADING'); + expect(files.testfile202021122).toHaveProperty('status', 'UPLOADING'); }); it('Given empty parameters, returns an empty object', () => {