Skip to content

Commit 0bea7a7

Browse files
committed
add assertion for added condition on template put
1 parent 7f0e709 commit 0bea7a7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,15 @@ describe('templateRepository', () => {
497497
async (channelProperties) => {
498498
const { templateRepository, mocks } = setup();
499499

500+
const template = {
501+
...channelProperties,
502+
...databaseTemplateProperties,
503+
};
504+
500505
mocks.ddbDocClient
501506
.on(PutCommand, {
502507
TableName: templatesTableName,
503-
Item: { ...channelProperties, ...databaseTemplateProperties },
508+
Item: template,
504509
})
505510
.resolves({});
506511

@@ -512,7 +517,13 @@ describe('templateRepository', () => {
512517
);
513518

514519
expect(response).toEqual({
515-
data: { ...channelProperties, ...databaseTemplateProperties },
520+
data: template,
521+
});
522+
523+
expect(mocks.ddbDocClient).toHaveReceivedCommandWith(PutCommand, {
524+
ConditionExpression: 'attribute_not_exists(id)',
525+
Item: template,
526+
TableName: templatesTableName,
516527
});
517528
}
518529
);

0 commit comments

Comments
 (0)