Skip to content
Snippets Groups Projects
Select Git revision
  • 09bbe45a717568f5ab4775084c60d109832e9a5f
  • dev default protected
  • renovate/major-nest-monorepo
  • renovate/luxon-3.x
  • renovate/gouvfr-anct-timetable-to-osm-opening-hours-2.x
  • renovate/major-typescript-eslint-monorepo
  • renovate/npm-11.x
  • renovate/mysql-9.x
  • renovate/mongo-express-1.x
  • renovate/major-jest-monorepo
  • renovate/tsconfig-paths-4.x
  • renovate/jest-junit-16.x
  • renovate/express-5.x
  • renovate/bitnami-mongodb-8.x
  • renovate/elastic-elasticsearch-8.x
  • renovate/ghost-5.x
  • renovate/ghcr.io-browserless-chromium-2.x
  • renovate/elasticsearch-7.x
  • renovate/devdependencies-(non-major)
  • 722-envsubst-client-side-conf
  • 168-pro-connect
  • v4.0.3
  • v4.0.1
  • v4.0.0
  • v3.4.3
  • v3.4.2
  • v3.4.1
  • v3.4.0
  • v3.3.1
  • v3.3.0
  • v3.2.0
  • v3.1.0
  • v3.0.1
  • v3.0.0
  • v2.5.0
  • v2.4.2
  • v2.4.1
  • v2.4.0
  • v2.3.2
  • v2.3.1
  • v2.3.0
41 results

mailer.service.spec.ts

Blame
  • user avatar
    Antonin Coquet authored
    1b1724ef
    History
    mailer.service.spec.ts 1.57 KiB
    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);
      });
    });