Skip to content

Commit

Permalink
fix history mocking in tests, lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnC-80 committed Oct 3, 2023
1 parent 8c4be23 commit c902dfa
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/routes/JobSummary/JobSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ const JobSummaryComponent = props => {
executionId={id}
fileName={jobExecutionsRecords[0]?.fileName}
/>
</Col>
)}
</Col>
)}
</Row>
<hr />
{!isErrorsOnly && (
Expand Down
2 changes: 1 addition & 1 deletion src/routes/JobSummary/JobSummary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const renderJobSummary = ({ dataType = 'MARC', resources, context = defaultUploa
search: '',
pathname: '',
}}
history={{ push: () => {} }}
history={history}
stripes={stripesMock}
/>
</UploadingJobsContext.Provider>
Expand Down
20 changes: 10 additions & 10 deletions src/routes/JobSummary/components/SourceDownloadLink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ 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();
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());
}
}));

Expand Down
1 change: 1 addition & 0 deletions src/routes/JobSummary/components/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './RecordsTable';
export * from './SummaryTable';
export * from './cells';
export * from './SourceDownloadLink';
1 change: 0 additions & 1 deletion src/routes/ViewAllLogs/ViewAllLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div data-test-logs-list>
Expand Down
16 changes: 10 additions & 6 deletions src/routes/ViewAllLogs/ViewAllLogs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ const mockFunctionalManifestProps = (loaded, splitStatus) => (
resources: {
splitStatus: {
hasLoaded: loaded,
records: [{ splitStatus: splitStatus }]
records: [{ splitStatus }]
}
}
}
)
);

const renderViewAllLogs = query => {
const component = (
Expand Down Expand Up @@ -581,7 +581,8 @@ describe('ViewAllLogs component', () => {
null,
queryData,
null,
mockFunctionalManifestProps(true, true));
mockFunctionalManifestProps(true, true)
);
expect(query.hrId).toEqual(expectedQuery);
});
});
Expand All @@ -606,7 +607,8 @@ describe('ViewAllLogs component', () => {
null,
queryData,
null,
mockFunctionalManifestProps(true, true));
mockFunctionalManifestProps(true, true)
);
expect(query).toMatchObject(expected);
});
});
Expand All @@ -626,7 +628,8 @@ describe('ViewAllLogs component', () => {
null,
queryData,
null,
mockFunctionalManifestProps(true, true));
mockFunctionalManifestProps(true, true)
);
expect(expectedSortBy).toEqual(query.sortBy);
});

Expand All @@ -643,7 +646,8 @@ describe('ViewAllLogs component', () => {
null,
queryData,
null,
mockFunctionalManifestProps(true, true));
mockFunctionalManifestProps(true, true)
);
expect(expectedSortBy).toEqual(query.sortBy);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tests/multipartUpload.test.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit c902dfa

Please sign in to comment.