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:
@@ -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.'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user