Skip to content

Commit ac2119a

Browse files
committed
update unit tests
1 parent e965a36 commit ac2119a

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed

lambdas/backend-api/src/__tests__/templates/api/proof.test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import { mock } from 'jest-mock-extended';
33
import { createHandler } from '@backend-api/templates/api/proof';
44
import { TemplateClient } from '@backend-api/templates/app/template-client';
55
import { LetterTemplate } from 'nhs-notify-web-template-management-utils';
6+
import { ProofingQueue } from '@backend-api/templates/infra/proofing-queue';
67

78
const setup = () => {
89
const templateClient = mock<TemplateClient>();
910

10-
const handler = createHandler({ templateClient });
11+
const proofingQueue = mock<ProofingQueue>();
1112

12-
return { handler, mocks: { templateClient } };
13+
const handler = createHandler({ templateClient, proofingQueue });
14+
15+
return { handler, mocks: { templateClient, proofingQueue } };
1316
};
1417

1518
describe('Template API - request proof', () => {
@@ -97,7 +100,8 @@ describe('Template API - request proof', () => {
97100

98101
expect(mocks.templateClient.requestProof).toHaveBeenCalledWith(
99102
'template-id',
100-
{ userId: 'sub', clientId: 'nhs-notify-client-id' }
103+
{ userId: 'sub', clientId: 'nhs-notify-client-id' },
104+
mocks.proofingQueue
101105
);
102106
});
103107

@@ -145,9 +149,13 @@ describe('Template API - request proof', () => {
145149
body: JSON.stringify({ statusCode: 200, data: response }),
146150
});
147151

148-
expect(mocks.templateClient.requestProof).toHaveBeenCalledWith('id', {
149-
userId: 'sub',
150-
clientId: 'notify-client-id',
151-
});
152+
expect(mocks.templateClient.requestProof).toHaveBeenCalledWith(
153+
'id',
154+
{
155+
userId: 'sub',
156+
clientId: 'notify-client-id',
157+
},
158+
mocks.proofingQueue
159+
);
152160
});
153161
});

lambdas/backend-api/src/__tests__/templates/app/template-client.test.ts

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const setup = () => {
4040
const templateClient = new TemplateClient(
4141
templateRepository,
4242
letterUploadRepository,
43-
queueMock,
4443
defaultLetterSupplier,
4544
clientConfigRepository,
4645
logger
@@ -1673,7 +1672,11 @@ describe('templateClient', () => {
16731672
data: { features: { proofing: false } },
16741673
});
16751674

1676-
const result = await templateClient.requestProof(templateId, user);
1675+
const result = await templateClient.requestProof(
1676+
templateId,
1677+
user,
1678+
mocks.queueMock
1679+
);
16771680

16781681
expect(
16791682
mocks.templateRepository.proofRequestUpdate
@@ -1696,7 +1699,11 @@ describe('templateClient', () => {
16961699
error: { errorMeta: { description: 'err', code: 500 } },
16971700
});
16981701

1699-
const result = await templateClient.requestProof(templateId, user);
1702+
const result = await templateClient.requestProof(
1703+
templateId,
1704+
user,
1705+
mocks.queueMock
1706+
);
17001707

17011708
expect(
17021709
mocks.templateRepository.proofRequestUpdate
@@ -1740,7 +1747,11 @@ describe('templateClient', () => {
17401747
},
17411748
});
17421749

1743-
const result = await templateClient.requestProof(templateId, user);
1750+
const result = await templateClient.requestProof(
1751+
templateId,
1752+
user,
1753+
mocks.queueMock
1754+
);
17441755

17451756
expect(mocks.templateRepository.proofRequestUpdate).toHaveBeenCalledWith(
17461757
templateId,
@@ -1801,7 +1812,11 @@ describe('templateClient', () => {
18011812
},
18021813
});
18031814

1804-
const result = await templateClient.requestProof(templateId, user);
1815+
const result = await templateClient.requestProof(
1816+
templateId,
1817+
user,
1818+
mocks.queueMock
1819+
);
18051820

18061821
expect(mocks.templateRepository.proofRequestUpdate).toHaveBeenCalledWith(
18071822
templateId,
@@ -1852,7 +1867,11 @@ describe('templateClient', () => {
18521867
},
18531868
});
18541869

1855-
const result = await templateClient.requestProof(templateId, user);
1870+
const result = await templateClient.requestProof(
1871+
templateId,
1872+
user,
1873+
mocks.queueMock
1874+
);
18561875

18571876
expect(mocks.templateRepository.proofRequestUpdate).toHaveBeenCalledWith(
18581877
templateId,
@@ -1920,7 +1939,11 @@ describe('templateClient', () => {
19201939
},
19211940
});
19221941

1923-
const result = await templateClient.requestProof(templateId, user);
1942+
const result = await templateClient.requestProof(
1943+
templateId,
1944+
user,
1945+
mocks.queueMock
1946+
);
19241947

19251948
expect(mocks.templateRepository.proofRequestUpdate).toHaveBeenCalledWith(
19261949
templateId,
@@ -1994,7 +2017,11 @@ describe('templateClient', () => {
19942017

19952018
mocks.queueMock.send.mockResolvedValueOnce({ data: { $metadata: {} } });
19962019

1997-
const result = await templateClient.requestProof(templateId, user);
2020+
const result = await templateClient.requestProof(
2021+
templateId,
2022+
user,
2023+
mocks.queueMock
2024+
);
19982025

19992026
expect(mocks.templateRepository.proofRequestUpdate).toHaveBeenCalledWith(
20002027
templateId,

0 commit comments

Comments
 (0)