Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnC-80 committed Sep 20, 2023
1 parent faa88d3 commit c768664
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions src/routes/ViewAllLogs/ViewAllLogs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

Expand All @@ -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', () => {
Expand Down
40 changes: 20 additions & 20 deletions src/utils/tests/compositeJobStatus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
};

Expand Down
48 changes: 24 additions & 24 deletions src/utils/tests/multipartUpload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
Expand All @@ -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();
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/tests/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit c768664

Please sign in to comment.