Skip to content

Commit

Permalink
PRMP-935 jest unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NogaNHS committed Oct 15, 2024
1 parent 816f336 commit 09948d1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/src/helpers/requests/getLloydGeorgeRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const requestStitchJob = async ({
patientId: nhsNumber,
},
});

return response.data.jobStatus;
};
export const pollForPresignedUrl = async ({
Expand All @@ -71,6 +72,7 @@ export const pollForPresignedUrl = async ({
baseHeaders,
}: Args): Promise<LloydGeorgeStitchResult> => {
const gatewayUrl = baseUrl + endpoints.LLOYDGEORGE_STITCH;

const { data } = await axios.get(gatewayUrl, {
headers: {
...baseHeaders,
Expand Down
4 changes: 2 additions & 2 deletions app/src/helpers/requests/getPresignedUrlForZip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('getPresignedUrlForZip', () => {
});

expect(mockWaitForSeconds).toHaveBeenCalledTimes(1);
expect(mockWaitForSeconds).toHaveBeenCalledWith(10);
expect(mockWaitForSeconds).toHaveBeenCalledWith(0);
});

it('wait for 10 secs between every polling', async () => {
Expand All @@ -108,7 +108,7 @@ describe('getPresignedUrlForZip', () => {
});

expect(mockWaitForSeconds).toHaveBeenCalledTimes(4);
expect(mockWaitForSeconds).toHaveBeenCalledWith(10);
expect(mockWaitForSeconds).toHaveBeenCalledWith(0);
});

it('throw an error if got pending status for 3 times', async () => {
Expand Down
2 changes: 1 addition & 1 deletion app/src/helpers/requests/uploadDocument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('virusScanResult', () => {
.mockRejectedValueOnce(gatewayTimeoutResponse)
.mockResolvedValueOnce(cleanResponse);

const delay_between_retry_in_seconds = 5;
const delay_between_retry_in_seconds = 0;

const result = await virusScan(virusScanArgs);

Expand Down
2 changes: 1 addition & 1 deletion app/src/helpers/test/testBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const buildSearchResult = (searchResultOverride?: Partial<SearchResult>) => {

const buildLgSearchResult = () => {
const result: LloydGeorgeStitchResult = {
jobStatus: 'Complete',
jobStatus: 'Completed',
numberOfFiles: 7,
totalFileSizeInByte: 7,
lastUpdated: '2023-10-03T09:11:54.618694Z',
Expand Down
2 changes: 1 addition & 1 deletion app/src/helpers/utils/isLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const isMock = (err: AxiosError) => isLocal && err.code === 'ERR_NETWORK'

export const isRunningInCypress = () => {
//@ts-ignore
return Boolean(window?.Cypress);
return Boolean(window?.Cypress) || typeof jest !== 'undefined';
};
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('LloydGeorgeRecordPage', () => {
});
});

xit('calls refreshRecord and updates state when successful', async () => {
it('calls refreshRecord and updates state when successful', async () => {
const lgResult = buildLgSearchResult();
mockAxios.post.mockResolvedValue({ data: { jobStatus: 'Complete' } });
mockAxios.get.mockResolvedValue({ data: lgResult });
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('LloydGeorgeRecordPage', () => {
});
});

xit('renders initial lg record view with file info when LG record is returned by search', async () => {
it('renders initial lg record view with file info when LG record is returned by search', async () => {
const lgResult = buildLgSearchResult();
mockAxios.post.mockResolvedValue({ data: { jobStatus: 'Pending' } });

Expand All @@ -207,7 +207,7 @@ describe('LloydGeorgeRecordPage', () => {
});

describe('Accessibility', () => {
xit('pass accessibility checks at page entry point', async () => {
it('pass accessibility checks at page entry point', async () => {
const lgResult = buildLgSearchResult();
mockAxios.post.mockResolvedValue({ data: { jobStatus: 'Pending' } });

Expand Down

0 comments on commit 09948d1

Please sign in to comment.