import { datatype } from 'faker' import { SendgridMailService, SENDGRID_DISABLED_MESSAGE } from './sendgrid.mail.service' jest.mock('@sendgrid/mail') describe('SendgridMailService', () => { let subject: SendgridMailService beforeAll(() => { subject = new SendgridMailService() }) describe('#send()', () => { describe('when sendgrid is disabled', () => { beforeAll(() => { globalThis.secret = { sendgrid_settings: { key: '', sender: '', profile: { logo: '', primary_color: '', website: '', }, enabled: false, }, } as any subject.onModuleInit() }) it('returns a default message for when sendgrid is disabled', async () => { const result = await subject.send({ templateId: datatype.uuid(), to: 'Gohan' }) expect(result).toEqual({ result: SENDGRID_DISABLED_MESSAGE, }) }) }) }) })