Skip to content

Commit

Permalink
feat: test/email-service (#191)
Browse files Browse the repository at this point in the history
* feat: test/email-service

* refactor: test-email-service
  • Loading branch information
Frompaje authored Sep 13, 2024
1 parent c260f3e commit f970ef0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { prisma } from 'mocks/prisma';
import { SocialMediaRepository } from '@/features/social-media/repositories/social-media';
import { SocialMediaMock } from '@/shared/test-helpers/mocks/social-media.mock';

describe('[Repositories] SocialMediaRepository', () => {
describe('[Service] SocialMediaRepository', () => {
let repository: SocialMediaRepository;
let socialMedias: any;

Expand Down
32 changes: 32 additions & 0 deletions src/shared/infra/email/services/email-service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { mock } from 'vitest-mock-extended';

import type { EmailAdapter } from '@/shared/infra/email/adapters/email-adapter';
import { EmailService } from '@/shared/infra/email/services/email-service';

describe('[Service] Email', () => {
let emailAdapter: EmailAdapter;
let emailService: EmailService;

beforeEach(() => {
emailAdapter = mock<EmailAdapter>({
sendEmail: vi.fn(),
});
emailService = new EmailService(emailAdapter);
});

describe('List', () => {
it('Should call the sendEmail method', async () => {
const data = {
parameters: { name: 'John Doe' },
recipient: 'johndoe@example.com',
subject: 'Test Subject',
template: 'test-template',
};

await emailService.sendEmail(data);

expect(emailAdapter.sendEmail).toBeCalledWith(data);
expect(emailAdapter.sendEmail).toHaveBeenCalledTimes(1);
});
});
});

0 comments on commit f970ef0

Please sign in to comment.