From c902dfa213e3eda882f50b57b68ddfb219fd707a Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 3 Oct 2023 16:04:48 -0500 Subject: [PATCH] fix history mocking in tests, lint --- src/routes/JobSummary/JobSummary.js | 4 ++-- src/routes/JobSummary/JobSummary.test.js | 2 +- .../components/SourceDownloadLink.test.js | 20 +++++++++---------- src/routes/JobSummary/components/index.js | 1 + src/routes/ViewAllLogs/ViewAllLogs.js | 1 - src/routes/ViewAllLogs/ViewAllLogs.test.js | 16 +++++++++------ src/utils/tests/multipartUpload.test.js | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/routes/JobSummary/JobSummary.js b/src/routes/JobSummary/JobSummary.js index 172f1f91c..444d6f191 100644 --- a/src/routes/JobSummary/JobSummary.js +++ b/src/routes/JobSummary/JobSummary.js @@ -211,8 +211,8 @@ const JobSummaryComponent = props => { executionId={id} fileName={jobExecutionsRecords[0]?.fileName} /> - - )} + + )}
{!isErrorsOnly && ( diff --git a/src/routes/JobSummary/JobSummary.test.js b/src/routes/JobSummary/JobSummary.test.js index a486688e6..7ddf64962 100644 --- a/src/routes/JobSummary/JobSummary.test.js +++ b/src/routes/JobSummary/JobSummary.test.js @@ -93,7 +93,7 @@ const renderJobSummary = ({ dataType = 'MARC', resources, context = defaultUploa search: '', pathname: '', }} - history={{ push: () => {} }} + history={history} stripes={stripesMock} /> diff --git a/src/routes/JobSummary/components/SourceDownloadLink.test.js b/src/routes/JobSummary/components/SourceDownloadLink.test.js index 2073b771a..b048e8b96 100644 --- a/src/routes/JobSummary/components/SourceDownloadLink.test.js +++ b/src/routes/JobSummary/components/SourceDownloadLink.test.js @@ -9,14 +9,14 @@ import '../../../utils/multipartUpload'; // the indirectly used ky library extends JS Errors with JS mockHTTPError. // this is used to simulate how we handle a 404 response. -class mockHTTPError extends Error { - constructor(response) { - super( - response.status - ); - this.name = 'HTTPError'; - this.response = response; - } +class MockHTTPError extends Error { + constructor(response) { + super( + response.status + ); + this.name = 'HTTPError'; + this.response = response; + } } const mockResponse = jest.fn(); @@ -24,9 +24,9 @@ jest.mock('../../../utils/multipartUpload', () => ({ ...jest.requireActual('../../../utils/multipartUpload'), getObjectStorageDownloadURL: (ky, id) => { if (id === 'file-removed') { - throw (new mockHTTPError({ status: '404'})); + throw (new MockHTTPError({ status: '404' })); } - return Promise.resolve(mockResponse()) + return Promise.resolve(mockResponse()); } })); diff --git a/src/routes/JobSummary/components/index.js b/src/routes/JobSummary/components/index.js index dcf95c74d..a862d7a54 100644 --- a/src/routes/JobSummary/components/index.js +++ b/src/routes/JobSummary/components/index.js @@ -1,3 +1,4 @@ export * from './RecordsTable'; export * from './SummaryTable'; export * from './cells'; +export * from './SourceDownloadLink'; diff --git a/src/routes/ViewAllLogs/ViewAllLogs.js b/src/routes/ViewAllLogs/ViewAllLogs.js index 8837aa4d6..492b41472 100644 --- a/src/routes/ViewAllLogs/ViewAllLogs.js +++ b/src/routes/ViewAllLogs/ViewAllLogs.js @@ -482,7 +482,6 @@ class ViewAllLogs extends Component { checkboxDisabled: isLogsDeletionInProgress, }); const itemToView = JSON.parse(sessionStorage.getItem(DATA_IMPORT_POSITION)); - const hasDeletePermission = stripes.hasPerm(DELETE_LOGS); return (
diff --git a/src/routes/ViewAllLogs/ViewAllLogs.test.js b/src/routes/ViewAllLogs/ViewAllLogs.test.js index 1feb5854f..495aac1f1 100644 --- a/src/routes/ViewAllLogs/ViewAllLogs.test.js +++ b/src/routes/ViewAllLogs/ViewAllLogs.test.js @@ -170,11 +170,11 @@ const mockFunctionalManifestProps = (loaded, splitStatus) => ( resources: { splitStatus: { hasLoaded: loaded, - records: [{ splitStatus: splitStatus }] + records: [{ splitStatus }] } } } -) +); const renderViewAllLogs = query => { const component = ( @@ -581,7 +581,8 @@ describe('ViewAllLogs component', () => { null, queryData, null, - mockFunctionalManifestProps(true, true)); + mockFunctionalManifestProps(true, true) + ); expect(query.hrId).toEqual(expectedQuery); }); }); @@ -606,7 +607,8 @@ describe('ViewAllLogs component', () => { null, queryData, null, - mockFunctionalManifestProps(true, true)); + mockFunctionalManifestProps(true, true) + ); expect(query).toMatchObject(expected); }); }); @@ -626,7 +628,8 @@ describe('ViewAllLogs component', () => { null, queryData, null, - mockFunctionalManifestProps(true, true)); + mockFunctionalManifestProps(true, true) + ); expect(expectedSortBy).toEqual(query.sortBy); }); @@ -643,7 +646,8 @@ describe('ViewAllLogs component', () => { null, queryData, null, - mockFunctionalManifestProps(true, true)); + mockFunctionalManifestProps(true, true) + ); expect(expectedSortBy).toEqual(query.sortBy); }); }); diff --git a/src/utils/tests/multipartUpload.test.js b/src/utils/tests/multipartUpload.test.js index 07716fb13..e52248ea9 100644 --- a/src/utils/tests/multipartUpload.test.js +++ b/src/utils/tests/multipartUpload.test.js @@ -1,4 +1,4 @@ -import { waitFor } from '@testing-library/react'; +import { waitFor } from '@folio/jest-config-stripes/testing-library/react'; import '../../../test/jest/__mock__'; import {