fix(core): update
This commit is contained in:
20
test/test.ts
20
test/test.ts
@ -4,16 +4,19 @@ import * as smartmail from '@pushrocks/smartmail';
|
||||
|
||||
const testQenv = new Qenv('./', './.nogit');
|
||||
|
||||
import * as mailgun from '../ts/index';
|
||||
import { IMailgunMessage } from '../ts/index';
|
||||
import * as mailgun from '../ts/index.js';
|
||||
import { IMailgunMessage } from '../ts/index.js';
|
||||
|
||||
let testMailgunAccount: mailgun.MailgunAccount;
|
||||
let testSmartmail: smartmail.Smartmail<IMailgunMessage>;
|
||||
|
||||
tap.test('should create a mailgun account', async () => {
|
||||
testMailgunAccount = new mailgun.MailgunAccount(testQenv.getEnvVarOnDemand('MAILGUN_API_TOKEN'));
|
||||
testMailgunAccount.addSmtpCredentials(testQenv.getEnvVarOnDemand('MAILGUN_SMTP_CREDENTIALS'));
|
||||
expect(testMailgunAccount).to.be.instanceOf(mailgun.MailgunAccount);
|
||||
testMailgunAccount = new mailgun.MailgunAccount({
|
||||
apiToken: testQenv.getEnvVarOnDemand('MAILGUN_API_TOKEN'),
|
||||
region: 'eu'
|
||||
});
|
||||
await testMailgunAccount.addSmtpCredentials(testQenv.getEnvVarOnDemand('MAILGUN_SMTP_CREDENTIALS'));
|
||||
expect(testMailgunAccount).toBeInstanceOf(mailgun.MailgunAccount);
|
||||
});
|
||||
|
||||
tap.test('should create a smartmail', async () => {
|
||||
@ -22,7 +25,7 @@ tap.test('should create a smartmail', async () => {
|
||||
from: 'Lossless GmbH <noreply@mail.lossless.com>',
|
||||
subject: 'TestMessage from @mojoio/mailgun test',
|
||||
});
|
||||
expect(testSmartmail).to.be.instanceOf(smartmail.Smartmail);
|
||||
expect(testSmartmail).toBeInstanceOf(smartmail.Smartmail);
|
||||
});
|
||||
|
||||
tap.test('should send a smartmail', async () => {
|
||||
@ -45,7 +48,10 @@ tap.test('should retrieve a mail using a retrieval url', async () => {
|
||||
const result = await testMailgunAccount.retrieveSmartMailFromMessageUrl(
|
||||
'https://sw.api.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA=='
|
||||
);
|
||||
if (result) {
|
||||
console.log(result);
|
||||
|
||||
// TODO handle empty body
|
||||
if (false) {
|
||||
result.options.subject = 'hi there. This is a testmail with attachment';
|
||||
result.options.from = 'noreply@mail.lossless.com';
|
||||
await testMailgunAccount.sendSmartMail(result, 'Sandbox Team <sandbox@mail.git.zone>');
|
||||
|
Reference in New Issue
Block a user