Merge pull request #54 from cwoac/nodemailer-passthrough
Nodemailer passthrough
This commit is contained in:
@@ -12,20 +12,21 @@ describe "Email", ->
|
||||
|
||||
@settings =
|
||||
email:
|
||||
ses:
|
||||
key: "key"
|
||||
secret: "secret"
|
||||
transport: "ses"
|
||||
parameters:
|
||||
AWSAccessKeyID: "key"
|
||||
AWSSecretKey: "secret"
|
||||
fromAddress: "bob@bob.com"
|
||||
replyToAddress: "sally@gmail.com"
|
||||
|
||||
@sesClient =
|
||||
sendemail: sinon.stub()
|
||||
@ses =
|
||||
createClient: => @sesClient
|
||||
@sesClient =
|
||||
sendMail: sinon.stub()
|
||||
@ses =
|
||||
createTransport: => @sesClient
|
||||
@sender = SandboxedModule.require modulePath, requires:
|
||||
'node-ses': @ses
|
||||
'nodemailer': @ses
|
||||
"settings-sharelatex":@settings
|
||||
"logger-sharelatex":
|
||||
"logger-sharelatex":
|
||||
log:->
|
||||
warn:->
|
||||
err:->
|
||||
@@ -38,44 +39,44 @@ describe "Email", ->
|
||||
describe "sendEmail", ->
|
||||
|
||||
it "should set the properties on the email to send", (done)->
|
||||
@sesClient.sendemail.callsArgWith(1)
|
||||
@sesClient.sendMail.callsArgWith(1)
|
||||
|
||||
@sender.sendEmail @opts, =>
|
||||
args = @sesClient.sendemail.args[0][0]
|
||||
args.message.should.equal @opts.html
|
||||
args = @sesClient.sendMail.args[0][0]
|
||||
args.html.should.equal @opts.html
|
||||
args.to.should.equal @opts.to
|
||||
args.subject.should.equal @opts.subject
|
||||
done()
|
||||
|
||||
it "should return the error", (done)->
|
||||
@sesClient.sendemail.callsArgWith(1, "error")
|
||||
it "should return the error", (done)->
|
||||
@sesClient.sendMail.callsArgWith(1, "error")
|
||||
@sender.sendEmail {}, (err)=>
|
||||
err.should.equal "error"
|
||||
done()
|
||||
|
||||
|
||||
it "should use the from address from settings", (done)->
|
||||
@sesClient.sendemail.callsArgWith(1)
|
||||
@sesClient.sendMail.callsArgWith(1)
|
||||
|
||||
@sender.sendEmail @opts, =>
|
||||
args = @sesClient.sendemail.args[0][0]
|
||||
args = @sesClient.sendMail.args[0][0]
|
||||
args.from.should.equal @settings.email.fromAddress
|
||||
done()
|
||||
|
||||
it "should use the reply to address from settings", (done)->
|
||||
@sesClient.sendemail.callsArgWith(1)
|
||||
@sesClient.sendMail.callsArgWith(1)
|
||||
|
||||
@sender.sendEmail @opts, =>
|
||||
args = @sesClient.sendemail.args[0][0]
|
||||
args = @sesClient.sendMail.args[0][0]
|
||||
args.replyTo.should.equal @settings.email.replyToAddress
|
||||
done()
|
||||
|
||||
|
||||
it "should use the reply to address in options as an override", (done)->
|
||||
@sesClient.sendemail.callsArgWith(1)
|
||||
@sesClient.sendMail.callsArgWith(1)
|
||||
|
||||
@opts.replyTo = "someone@else.com"
|
||||
@sender.sendEmail @opts, =>
|
||||
args = @sesClient.sendemail.args[0][0]
|
||||
args = @sesClient.sendMail.args[0][0]
|
||||
args.replyTo.should.equal @opts.replyTo
|
||||
done()
|
||||
|
||||
Reference in New Issue
Block a user