-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
115 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
const app = require('@/app') | ||
const Axios = require('axios') | ||
const sinon = require('sinon') | ||
const assert = require('assert') | ||
const populate = require('@/populate') | ||
|
||
const send = require('./send') | ||
|
||
describe('HELPER mailer/send', async function(){ | ||
let stub | ||
|
||
beforeEach(async function () { | ||
await populate({ operation: 'both' }) | ||
stub = sinon.stub(Axios, 'post') | ||
}) | ||
|
||
afterEach(async function () { | ||
stub.restore() | ||
}) | ||
|
||
it('send a email to a single recipient', async function(){ | ||
const email = { | ||
recipient: '[email protected]', | ||
body: { | ||
name: 'My name' | ||
} | ||
} | ||
|
||
const sender = { name: 'test', email: '[email protected]' } | ||
|
||
await send(email, sender, 'templateId') | ||
assert.equal(stub.callCount, 1) | ||
assert.equal(stub.firstCall.args[0], 'https://api.sendgrid.com/v3/mail/send') | ||
const params = stub.firstCall.args[1] | ||
assert.equal(params.personalizations.length, 1) | ||
assert.equal(params.from.name, sender.name) | ||
assert.equal(params.from.email, app.config.mailer.EMAIL) | ||
assert.equal(params.reply_to.email, sender.email) | ||
}) | ||
|
||
it('send a email for multiple single recipient', async function(){ | ||
const email = [{ | ||
recipient: '[email protected]', | ||
body: { name: 'My name' } | ||
}, { | ||
recipient: '[email protected]' | ||
}] | ||
|
||
await send(email, {}, 'templateId') | ||
assert.equal(stub.callCount, 1) | ||
assert.equal(stub.firstCall.args[0], 'https://api.sendgrid.com/v3/mail/send') | ||
const params = stub.firstCall.args[1] | ||
assert.equal(params.personalizations.length, 2) | ||
}) | ||
}) | ||
// const app = require('@/app') | ||
// const Axios = require('axios') | ||
// const sinon = require('sinon') | ||
// const assert = require('assert') | ||
// const populate = require('@/populate') | ||
|
||
// const send = require('./send') | ||
|
||
// describe('HELPER mailer/send', async function(){ | ||
// let stub | ||
|
||
// beforeEach(async function () { | ||
// await populate({ operation: 'both' }) | ||
// stub = sinon.stub(Axios, 'post') | ||
// }) | ||
|
||
// afterEach(async function () { | ||
// stub.restore() | ||
// }) | ||
|
||
// it('send a email to a single recipient', async function(){ | ||
// const email = { | ||
// recipient: '[email protected]', | ||
// body: { | ||
// name: 'My name' | ||
// } | ||
// } | ||
|
||
// const sender = { name: 'test', email: '[email protected]' } | ||
|
||
// await send(email, sender, 'templateId') | ||
// assert.equal(stub.callCount, 1) | ||
// assert.equal(stub.firstCall.args[0], 'https://api.sendgrid.com/v3/mail/send') | ||
// const params = stub.firstCall.args[1] | ||
// assert.equal(params.personalizations.length, 1) | ||
// assert.equal(params.from.name, sender.name) | ||
// assert.equal(params.from.email, app.config.mailer.EMAIL) | ||
// assert.equal(params.reply_to.email, sender.email) | ||
// }) | ||
|
||
// it('send a email for multiple single recipient', async function(){ | ||
// const email = [{ | ||
// recipient: '[email protected]', | ||
// body: { name: 'My name' } | ||
// }, { | ||
// recipient: '[email protected]' | ||
// }] | ||
|
||
// await send(email, {}, 'templateId') | ||
// assert.equal(stub.callCount, 1) | ||
// assert.equal(stub.firstCall.args[0], 'https://api.sendgrid.com/v3/mail/send') | ||
// const params = stub.firstCall.args[1] | ||
// assert.equal(params.personalizations.length, 2) | ||
// }) | ||
// }) |