Skip to content

Commit 3f624ed

Browse files
committed
CCM-9692: more submit tests
1 parent 86d85b2 commit 3f624ed

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

lambdas/backend-api/src/__tests__/templates/infra/template-repository.test.ts

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,24 @@ describe('templateRepository', () => {
511511
},
512512
{
513513
testName:
514-
'Fails when user tries to submit template when templateStatus is not NOT_YET_SUBMITTED',
514+
'Fails when user tries to submit template when templateStatus is PENDING_UPLOAD',
515515
Item: marshall({
516516
templateType: 'LETTER',
517517
templateStatus: 'PENDING_UPLOAD',
518518
}),
519519
code: 400,
520520
message: 'Template cannot be submitted',
521521
},
522+
{
523+
testName:
524+
'Fails when user tries to submit template when templateStatus is PENDING_VALIDATION',
525+
Item: marshall({
526+
templateType: 'LETTER',
527+
templateStatus: 'PENDING_VALIDATION',
528+
}),
529+
code: 400,
530+
message: 'Template cannot be submitted',
531+
},
522532
{
523533
testName:
524534
'Fails when user tries to submit template when templateStatus is DELETED',
@@ -551,33 +561,30 @@ describe('templateRepository', () => {
551561
code: 400,
552562
message: 'Template cannot be submitted',
553563
},
554-
])(
555-
'should return error when, ConditionalCheckFailedException occurs and no Item is returned %p',
556-
async ({ Item, code, message }) => {
557-
const { templateRepository, mocks } = setup();
564+
])('submit: $testName', async ({ Item, code, message }) => {
565+
const { templateRepository, mocks } = setup();
558566

559-
const error = new ConditionalCheckFailedException({
560-
message: 'mocked',
561-
$metadata: { httpStatusCode: 400 },
562-
Item,
563-
});
567+
const error = new ConditionalCheckFailedException({
568+
message: 'mocked',
569+
$metadata: { httpStatusCode: 400 },
570+
Item,
571+
});
564572

565-
mocks.ddbDocClient.on(UpdateCommand).rejects(error);
573+
mocks.ddbDocClient.on(UpdateCommand).rejects(error);
566574

567-
const response = await templateRepository.submit(
568-
'abc-def-ghi-jkl-123',
569-
'real-owner'
570-
);
575+
const response = await templateRepository.submit(
576+
'abc-def-ghi-jkl-123',
577+
'real-owner'
578+
);
571579

572-
expect(response).toEqual({
573-
error: {
574-
code,
575-
message,
576-
actualError: error,
577-
},
578-
});
579-
}
580-
);
580+
expect(response).toEqual({
581+
error: {
582+
code,
583+
message,
584+
actualError: error,
585+
},
586+
});
587+
});
581588

582589
test('should return error when, an unexpected error occurs', async () => {
583590
const { templateRepository, mocks } = setup();

0 commit comments

Comments
 (0)