Newer
Older
import { HttpModule } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ConfigurationService } from '../configuration/configuration.service';
import { MailerService } from './mailer.service';
describe('MailerService', () => {
let service: MailerService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [HttpModule],
providers: [MailerService, ConfigurationService],
}).compile();
service = module.get<MailerService>(MailerService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
it('should send email', async () => {
const result = "AxiosResponse"
jest.spyOn(service, 'send').mockImplementation(async (): Promise<any> => result);
expect(await service.send("to", "subject", "html")).toBe(result);
});
it('should get template location', async () => {
const result = "/path/to/template";
jest.spyOn(service, 'getTemplateLocation').mockImplementation(() => {return result});
expect(await service.getTemplateLocation("filename")).toBe(result);
});
it('should load Json Config', async () => {
const result = null;
jest.spyOn(service, 'loadJsonConfig').mockImplementation(async (): Promise<any> => result);
expect(await service.loadJsonConfig("filename")).toBe(result);
});
it('should add signature', async () => {
const result = "signed html";
jest.spyOn(service, 'addSignature').mockImplementation(() => {return result});
expect(await service.addSignature("html")).toBe(result);
});