Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trslater committed Sep 11, 2024
1 parent 6fd0d2b commit e35407f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { classes } from 'automapper-classes';
import { AutomapperModule } from 'automapper-nestjs';
import { ClsService } from 'nestjs-cls';
import { generateCANCApplicationHtml } from '../../../../../templates/emails/cancelled';
import { template } from '../../../../../templates/emails/cancelled/application.template';
import {
initApplicationMockEntity,
initMockAssigneeDto,
Expand Down Expand Up @@ -426,7 +426,7 @@ describe('ApplicationController', () => {
1,
);
expect(statusEmailService.sendApplicationStatusEmail).toHaveBeenCalledWith({
generateStatusHtml: generateCANCApplicationHtml,
template,
status: SUBMISSION_STATUS.CANCELLED,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { BaseServiceException } from '@app/common/exceptions/base.exception';
import { createMock, DeepMocked } from '@golevelup/nestjs-testing';
import { Test, TestingModule } from '@nestjs/testing';
import { ClsService } from 'nestjs-cls';
import { generateRFFGHtml } from '../../../../../templates/emails/refused-to-forward.template';
import { generateINCMHtml } from '../../../../../templates/emails/returned-as-incomplete.template';
import { generateSUBMApplicationHtml } from '../../../../../templates/emails/submitted-to-alc';
import { generateWRNGHtml } from '../../../../../templates/emails/wrong-lfng.template';
import { template as rffgTemplate } from '../../../../../templates/emails/refused-to-forward.template';
import { template as incmTemplate } from '../../../../../templates/emails/returned-as-incomplete.template';
import { template as submApplicationTemplate } from '../../../../../templates/emails/submitted-to-alc/application.template';
import { template as wrngTemplate } from '../../../../../templates/emails/wrong-lfng.template';
import { mockKeyCloakProviders } from '../../../test/mocks/mockTypes';
import { ApplicationDocument } from '../../alcs/application/application-document/application-document.entity';
import { ApplicationDocumentService } from '../../alcs/application/application-document/application-document.service';
Expand Down Expand Up @@ -381,7 +381,7 @@ describe('ApplicationSubmissionReviewController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBMApplicationHtml,
template: submApplicationTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: mockSubmission,
government: mockLG,
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('ApplicationSubmissionReviewController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateRFFGHtml,
template: rffgTemplate,
status: SUBMISSION_STATUS.REFUSED_TO_FORWARD_LG,
applicationSubmission: mockSubmission,
government: mockLG,
Expand Down Expand Up @@ -559,7 +559,7 @@ describe('ApplicationSubmissionReviewController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateINCMHtml,
template: incmTemplate,
status: SUBMISSION_STATUS.INCOMPLETE,
applicationSubmission: mockSubmission,
government: mockLG,
Expand Down Expand Up @@ -638,7 +638,7 @@ describe('ApplicationSubmissionReviewController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateWRNGHtml,
template: wrngTemplate,
status: SUBMISSION_STATUS.WRONG_GOV,
applicationSubmission: mockSubmission,
government: mockLG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ import { classes } from 'automapper-classes';
import { AutomapperModule } from 'automapper-nestjs';
import { ClsService } from 'nestjs-cls';
import { ServiceValidationException } from '../../../../../libs/common/src/exceptions/base.exception';
import { generateCANCApplicationHtml } from '../../../../../templates/emails/cancelled';
import {
generateSUBGNoReviewGovernmentTemplateEmail,
generateSUBGTurApplicantHtml,
} from '../../../../../templates/emails/submitted-to-alc';
import {
generateSUBGApplicantHtml,
generateSUBGGovernmentHtml,
} from '../../../../../templates/emails/submitted-to-lfng';
import { template as cancApplicationTemplate } from '../../../../../templates/emails/cancelled/application.template';
import { template as subgNoReviewGovernmentTemplate } from '../../../../../templates/emails/submitted-to-alc/no-review-government.template';
import { template as subgTurApplicantTemplate } from '../../../../../templates/emails/submitted-to-alc/tur-applicant.template';
import { template as subgApplicantTemplate } from '../../../../../templates/emails/submitted-to-lfng/applicant.template';
import { template as subgGovernmentTemplate } from '../../../../../templates/emails/submitted-to-lfng/government.template';
import { mockKeyCloakProviders } from '../../../test/mocks/mockTypes';
import { ApplicationDocumentService } from '../../alcs/application/application-document/application-document.service';
import { ApplicationSubmissionStatusType } from '../../alcs/application/application-submission-status/submission-status-type.entity';
Expand Down Expand Up @@ -289,7 +285,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateCANCApplicationHtml,
template: cancApplicationTemplate,
status: SUBMISSION_STATUS.CANCELLED,
applicationSubmission: mockApplication,
government: mockGovernment,
Expand Down Expand Up @@ -531,7 +527,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGTurApplicantHtml,
template: subgTurApplicantTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand All @@ -542,7 +538,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGNoReviewGovernmentTemplateEmail,
template: subgNoReviewGovernmentTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand Down Expand Up @@ -595,7 +591,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGApplicantHtml,
template: subgApplicantTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_LG,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand All @@ -606,7 +602,7 @@ describe('ApplicationSubmissionController', () => {
expect(
mockStatusEmailService.sendApplicationStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBGGovernmentHtml,
template: subgGovernmentTemplate,
status: SUBMISSION_STATUS.SUBMITTED_TO_LG,
applicationSubmission: mockApplicationSubmission,
government: mockGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { Test, TestingModule } from '@nestjs/testing';
import { classes } from 'automapper-classes';
import { AutomapperModule } from 'automapper-nestjs';
import { ClsService } from 'nestjs-cls';
import {
generateSUBMNoiApplicantHtml,
generateSUBMNoiGovernmentHtml,
} from '../../../../../templates/emails/submitted-to-alc';
import { template as submNoiApplicantTemplate } from '../../../../../templates/emails/submitted-to-alc/noi-applicant.template';
import { template as submNoiGovernmentTemplate } from '../../../../../templates/emails/submitted-to-alc/noi-government.template';
import { mockKeyCloakProviders } from '../../../test/mocks/mockTypes';
import { LocalGovernment } from '../../alcs/local-government/local-government.entity';
import { LocalGovernmentService } from '../../alcs/local-government/local-government.service';
Expand Down Expand Up @@ -391,7 +389,7 @@ describe('NoticeOfIntentSubmissionController', () => {
expect(
mockStatusEmailService.sendNoticeOfIntentStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBMNoiApplicantHtml,
template: submNoiApplicantTemplate,
status: NOI_SUBMISSION_STATUS.SUBMITTED_TO_ALC,
noticeOfIntentSubmission: mockSubmission,
government: mockGovernment,
Expand All @@ -402,7 +400,7 @@ describe('NoticeOfIntentSubmissionController', () => {
expect(
mockStatusEmailService.sendNoticeOfIntentStatusEmail,
).toHaveBeenCalledWith({
generateStatusHtml: generateSUBMNoiGovernmentHtml,
template: submNoiGovernmentTemplate,
status: NOI_SUBMISSION_STATUS.SUBMITTED_TO_ALC,
noticeOfIntentSubmission: mockSubmission,
government: mockGovernment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { CONFIG_TOKEN, ConfigModule } from '@app/common/config/config.module';
import { createMock, DeepMocked } from '@golevelup/nestjs-testing';
import { Test, TestingModule } from '@nestjs/testing';
import * as config from 'config';
import { MJMLParseResults } from 'mjml-core';
import { ApplicationDecisionDocument } from '../../alcs/application-decision/application-decision-document/application-decision-document.entity';
import { ApplicationDecisionV2Service } from '../../alcs/application-decision/application-decision-v2/application-decision/application-decision-v2.service';
import { ApplicationDecision } from '../../alcs/application-decision/application-decision.entity';
Expand Down Expand Up @@ -225,7 +224,7 @@ describe('StatusEmailService', () => {

it('should call through services to set application email template', async () => {
const mockData: ApplicationEmailData = {
generateStatusHtml: () => ({}) as MJMLParseResults,
template: 'test',
status: SUBMISSION_STATUS.IN_REVIEW_BY_LG,
applicationSubmission: new ApplicationSubmission({ typeCode: 'TURP' }),
parentType: 'application' as PARENT_TYPE,
Expand All @@ -251,7 +250,7 @@ describe('StatusEmailService', () => {

it('should call through services to set notice of intent email template', async () => {
const mockData: NoticeOfIntentEmailData = {
generateStatusHtml: () => ({}) as MJMLParseResults,
template: 'test',
status: NOI_SUBMISSION_STATUS.SUBMITTED_TO_ALC,
noticeOfIntentSubmission: new NoticeOfIntentSubmission(),
parentType: 'notice-of-intent' as PARENT_TYPE,
Expand Down Expand Up @@ -280,7 +279,7 @@ describe('StatusEmailService', () => {
it('should add CC emails to the send call', async () => {
const ccEmails = ['bruce.wayne@fakeemail.com', 'iam.batman@fakeemail.com'];
const mockData: NoticeOfIntentEmailData = {
generateStatusHtml: () => ({}) as MJMLParseResults,
template: 'test',
status: NOI_SUBMISSION_STATUS.SUBMITTED_TO_ALC,
noticeOfIntentSubmission: new NoticeOfIntentSubmission(),
parentType: 'notice-of-intent' as PARENT_TYPE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createMock, DeepMocked } from '@golevelup/nestjs-testing';
import { Test, TestingModule } from '@nestjs/testing';
import { generateALCDApplicationHtml } from '../../../../../../../templates/emails/decision-released';
import { template } from '../../../../../../../templates/emails/decision-released/application.template';
import { ApplicationDecisionV2Service } from '../../../../alcs/application-decision/application-decision-v2/application-decision/application-decision-v2.service';
import { ApplicationDecision } from '../../../../alcs/application-decision/application-decision.entity';
import { ApplicationSubmissionStatusService } from '../../../../alcs/application/application-submission-status/application-submission-status.service';
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('ApplicationDecisionEmailConsumer', () => {
parentType: PARENT_TYPE.APPLICATION,
primaryContact: mockPrimaryContact,
ccGovernment: true,
generateStatusHtml: generateALCDApplicationHtml,
template,
status: SUBMISSION_STATUS.ALC_DECISION,
documents: mockDocuments,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createMock, DeepMocked } from '@golevelup/nestjs-testing';
import { Test, TestingModule } from '@nestjs/testing';
import { generateREVAHtml } from '../../../../../../../templates/emails/under-review-by-alc.template';
import { template } from '../../../../../../../templates/emails/under-review-by-alc.template';
import { ApplicationSubmissionStatusService } from '../../../../alcs/application/application-submission-status/application-submission-status.service';
import { SUBMISSION_STATUS } from '../../../../alcs/application/application-submission-status/submission-status.dto';
import { ApplicationSubmissionToSubmissionStatus } from '../../../../alcs/application/application-submission-status/submission-status.entity';
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('ApplicationSubmissionStatusEmailConsumer', () => {
parentType: PARENT_TYPE.APPLICATION,
primaryContact: mockPrimaryContact,
ccGovernment: true,
generateStatusHtml: generateREVAHtml,
template,
status: SUBMISSION_STATUS.IN_REVIEW_BY_ALC,
documents: [],
ccEmails: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createMock, DeepMocked } from '@golevelup/nestjs-testing';
import { Test, TestingModule } from '@nestjs/testing';
import { generateALCDNoticeOfIntentHtml } from '../../../../../../templates/emails/decision-released';
import { template } from '../../../../../../templates/emails/decision-released/notice-of-intent.template';
import { PARENT_TYPE } from '../../../alcs/card/card-subtask/card-subtask.dto';
import { LocalGovernment } from '../../../alcs/local-government/local-government.entity';
import { NoticeOfIntentDecisionV2Service } from '../../../alcs/notice-of-intent-decision/notice-of-intent-decision-v2/notice-of-intent-decision-v2.service';
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('NoticeOfIntentDecisionEmailsConsumer', () => {
parentType: PARENT_TYPE.NOTICE_OF_INTENT,
primaryContact: mockPrimaryContact,
ccGovernment: true,
generateStatusHtml: generateALCDNoticeOfIntentHtml,
template,
status: NOI_SUBMISSION_STATUS.ALC_DECISION,
documents: mockDocuments,
});
Expand Down

0 comments on commit e35407f

Please sign in to comment.