Skip to content

Commit

Permalink
[PRMDR-803] use test builder
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelHowellNHS committed May 16, 2024
1 parent 6f3bbfa commit 01c941a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import usePatient from '../../../../helpers/hooks/usePatient';
import { buildPatientDetails } from '../../../../helpers/test/testBuilders';
import { buildPatientDetails, buildSearchResult } from '../../../../helpers/test/testBuilders';
import { render, screen, waitFor } from '@testing-library/react';
import LloydGeorgeDownloadComplete from './LloydGeorgeDownloadComplete';
import userEvent from '@testing-library/user-event';
Expand All @@ -18,24 +18,9 @@ const numberOfFiles = 7;
const selectedDocuments = ['test-id-1', 'test-id-2'];
const downloadAllSelectedDocuments: Array<string> = [];
const searchResults = [
{
fileName: '1of2_test.pdf',
created: '2024-01-01T14:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'test-id-1',
},
{
fileName: '2of2_test.pdf',
created: '2024-01-01T14:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'test-id-2',
},
{
fileName: '1of1_test.pdf',
created: '2024-02-01T14:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'test-id-3',
},
buildSearchResult({ fileName: '1of2_test.pdf', ID: 'test-id-1' }),
buildSearchResult({ fileName: '2of2_test.pdf', ID: 'test-id-2' }),
buildSearchResult({ fileName: '1of1_test.pdf', ID: 'test-id-3' }),
];

describe('LloydGeorgeDownloadComplete', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { isMock } from '../../../../helpers/utils/isLocal';
import LloydGeorgeSelectSearchResults from '../lloydGeorgeSelectSearchResults/LloydGeorgeSelectSearchResults';
import PatientSummary from '../../../generic/patientSummary/PatientSummary';
import LloydGeorgeDownloadStage from '../lloydGeorgeDownloadAllStage/LloydGeorgeDownloadStage';
import { buildSearchResult } from '../../../../helpers/test/testBuilders';

export type Props = {
setStage: Dispatch<SetStateAction<LG_RECORD_STAGE>>;
Expand Down Expand Up @@ -62,48 +63,8 @@ function LloydGeorgeSelectDownloadStage({
const error = e as AxiosError;
if (isMock(error)) {
setSearchResults([
{
fileName: '2of3_testy_test.pdf',
created: '2024-05-07T14:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'test-id-2',
},
{
fileName: '1of3_testy_test.pdf',
created: '2024-05-07T14:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'test-id',
},
{
fileName: '3of3_testy_test.pdf',
created: '2024-05-07T14:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'test-id-3',
},
{
fileName: '2of3_earlier_creation_date.pdf',
created: '2024-05-07T13:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'earlier-test-id-2',
},
{
fileName: '1of3_earlier_creation_date.pdf',
created: '2024-05-07T13:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'earlier-test-id',
},
{
fileName: '3of3_earlier_creation_date.pdf',
created: '2024-05-07T13:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'earlier-test-id-3',
},
{
fileName: '11of20_earlier_creation_date.pdf',
created: '2024-05-07T13:52:00.827602Z',
virusScannerResult: 'Clean',
ID: 'test-id-3',
},
buildSearchResult(),
buildSearchResult({ fileName: 'fileName2.pdf', ID: '1234qwer-241ewewr-2' }),
]);
setSubmissionSearchState(SEARCH_AND_DOWNLOAD_STATE.SEARCH_SUCCEEDED);
} else if (error.response?.status === 403) {
Expand Down

0 comments on commit 01c941a

Please sign in to comment.