Send email via Parse.Cloud.sendEmail (#7096)

* initial

* more tests

* Update CHANGELOG.md

* review

* log on error

* change logger to error

* rename

* Update Parse.Cloud.js
This commit is contained in:
dblythy
2020-12-31 03:23:44 +11:00
committed by GitHub
parent 029edbf706
commit d47891f7e3
3 changed files with 59 additions and 0 deletions

View File

@@ -3168,3 +3168,29 @@ describe('afterLogin hook', () => {
await query.find({ context: { a: 'a' } });
});
});
describe('sendEmail', () => {
it('can send email via Parse.Cloud', async done => {
const emailAdapter = {
sendMail: mailData => {
expect(mailData).toBeDefined();
expect(mailData.to).toBe('test');
done();
},
};
await reconfigureServer({
emailAdapter: emailAdapter,
});
const mailData = { to: 'test' };
await Parse.Cloud.sendEmail(mailData);
});
it('cannot send email without adapter', async () => {
const logger = require('../lib/logger').logger;
spyOn(logger, 'error').and.callFake(() => {});
await Parse.Cloud.sendEmail({});
expect(logger.error).toHaveBeenCalledWith(
'Failed to send email because no mail adapter is configured for Parse Server.'
);
});
});