From 1759dd993ae9356c636e85c4d736c3553c5ec7cd Mon Sep 17 00:00:00 2001 From: teekay Date: Mon, 11 Nov 2024 11:14:31 -0500 Subject: [PATCH] Add tests --- AzureCommentsApiDelete/index.ts | 1 - src/shared/emails/email.service.spec.ts | 33 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/shared/emails/email.service.spec.ts diff --git a/AzureCommentsApiDelete/index.ts b/AzureCommentsApiDelete/index.ts index f38b6fc..3c58937 100644 --- a/AzureCommentsApiDelete/index.ts +++ b/AzureCommentsApiDelete/index.ts @@ -25,7 +25,6 @@ const commentsApi: AzureFunction = async function (context: Context, req: HttpRe } const forDate = new Date() - console.log(`Date: ${forDate}`) const signatureVerificationResult = await authService.isHmacSignatureValid( 'DELETE', diff --git a/src/shared/emails/email.service.spec.ts b/src/shared/emails/email.service.spec.ts new file mode 100644 index 0000000..01cf6a7 --- /dev/null +++ b/src/shared/emails/email.service.spec.ts @@ -0,0 +1,33 @@ +import { Comment } from "../comments/comment.interface" +import { EmailService } from "./email.service" + +describe('Email Service', () => { + const emailSvc = new EmailService() + const comment: Comment = { + id: "foo", + account: { + id: "bar", + username: "tester", + email: "test@test.com", + createdAt: new Date(), + }, + author: { + name: "John Doe", + email: "john.doe@test.com", + website: "http://johndoe.com" + }, + postUrl: "http://test.com/post", + text: "This is a test comment", + postedAt: new Date(), + } + + it('should include comment ID in the output', () => { + const result = emailSvc.notifyOnSingleComment( + comment, + 'https://foobar.com/dashboard/123' + ) + + expect(result.text).toContain(comment.id) + expect(result.html).toContain(comment.id) + }) +}) \ No newline at end of file