Skip to content

Commit 985c8f4

Browse files
committed
more tests
1 parent 13c5184 commit 985c8f4

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

spec/CloudCode.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,4 +3181,12 @@ describe('afterLogin hook', () => {
31813181
const mailData = { to: 'test' };
31823182
await Parse.Cloud.sendMail(mailData);
31833183
});
3184+
it('cannot send email without adapter', async () => {
3185+
try {
3186+
await Parse.Cloud.sendMail({});
3187+
fail('Should have failed to send emails.');
3188+
} catch (e) {
3189+
expect(e).toBe('You cannot send mail without an email adapter');
3190+
}
3191+
});
31843192
});

src/cloud-code/Parse.Cloud.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,15 +546,11 @@ ParseCloud.beforeConnect = function (handler, validationHandler) {
546546
*/
547547
ParseCloud.sendMail = function (data) {
548548
const config = Config.get(Parse.applicationId) || {};
549-
const emailAdapter = config.emailAdapter;
549+
const emailAdapter = config.userController.adapter;
550550
if (!emailAdapter) {
551551
throw 'You cannot send mail without an email adapter';
552552
}
553-
const sendMail = emailAdapter.sendMail;
554-
if (!sendMail || typeof sendMail !== 'function') {
555-
throw 'This adapter does not support sendMail';
556-
}
557-
return sendMail(data);
553+
return emailAdapter.sendMail(data);
558554
};
559555

560556
/**

0 commit comments

Comments
 (0)