Skip to content

Commit

Permalink
fix(unit test): fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juandav committed Dec 12, 2019
1 parent 31db118 commit c3bc61e
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 848 deletions.
8 changes: 4 additions & 4 deletions lib/mailer.service.spec.ts
Expand Up @@ -24,8 +24,7 @@ async function getMailerServiceForOptions(
]
}).compile();

const service = module.get<MailerService>(MailerService);

const service = module.get<MailerService>(MailerService);
return service;
}

Expand All @@ -46,6 +45,7 @@ function spyOnSmtpSend(onMail: (mail: MailMessage) => void) {
}

describe("MailerService", () => {

it("should not be defined if a transport is not provided", async () => {
await expect(getMailerServiceForOptions({})).rejects.toMatchInlineSnapshot(
`[Error: Make sure to provide a nodemailer transport configuration object, connection url or a transport plugin instance.]`
Expand Down Expand Up @@ -156,13 +156,13 @@ describe("MailerService", () => {
subject: 'Test',
template: __dirname + '/test-templates/handlebars-template',
context: {
world: 'World',
MAILER: 'Nest-modules TM',
},
});

expect(send).toHaveBeenCalled();
expect(lastMail.data.from).toBe('user1@example.test');
expect(lastMail.data.html).toBe('<p>Handlebars test template.</p>\n<p>Hello World!</p>\n');
expect(lastMail.data.html).toBe('<p>Handlebars test template. by Nest-modules TM</p>');
});

it('should compile template with the pug adapter', async () => {
Expand Down
3 changes: 1 addition & 2 deletions lib/test-templates/handlebars-template.hbs
@@ -1,2 +1 @@
<p>Handlebars test template.</p>
<p>Hello {{world}}!</p>
<p>Handlebars test template. by {{MAILER}}</p>

0 comments on commit c3bc61e

Please sign in to comment.