2014-03-04 13:10:06 -05:00
|
|
|
should = require('chai').should()
|
|
|
|
SandboxedModule = require('sandboxed-module')
|
|
|
|
assert = require('assert')
|
|
|
|
path = require('path')
|
|
|
|
sinon = require('sinon')
|
2014-03-05 06:22:34 -05:00
|
|
|
modulePath = path.join __dirname, "../../../../app/js/Features/Email/EmailBuilder"
|
2014-03-04 13:10:06 -05:00
|
|
|
expect = require("chai").expect
|
|
|
|
_ = require('underscore')
|
|
|
|
_.templateSettings =
|
|
|
|
interpolate: /\{\{(.+?)\}\}/g
|
|
|
|
|
2016-03-09 07:51:19 -05:00
|
|
|
describe "EmailBuilder", ->
|
2014-03-04 13:10:06 -05:00
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
|
2015-03-19 12:41:09 -04:00
|
|
|
@settings = appName: "testApp"
|
2014-03-05 06:22:34 -05:00
|
|
|
@EmailBuilder = SandboxedModule.require modulePath, requires:
|
2014-03-04 13:10:06 -05:00
|
|
|
"settings-sharelatex":@settings
|
|
|
|
"logger-sharelatex": log:->
|
|
|
|
|
|
|
|
describe "projectSharedWithYou", ->
|
|
|
|
beforeEach ->
|
|
|
|
@opts =
|
|
|
|
to:"bob@bob.com"
|
|
|
|
first_name:"bob"
|
|
|
|
owner:
|
|
|
|
email:"sally@hally.com"
|
|
|
|
project:
|
|
|
|
url:"http://www.project.com"
|
|
|
|
name:"standard project"
|
2014-03-05 06:22:34 -05:00
|
|
|
@email = @EmailBuilder.buildEmail("projectSharedWithYou", @opts)
|
2014-03-04 13:10:06 -05:00
|
|
|
|
|
|
|
it "should insert the owner email into the template", ->
|
|
|
|
@email.html.indexOf(@opts.owner.email).should.not.equal -1
|
|
|
|
@email.subject.indexOf(@opts.owner.email).should.not.equal -1
|
|
|
|
|
2016-10-03 10:25:38 -04:00
|
|
|
it 'should not have text component', ->
|
|
|
|
expect(@email.html?).to.equal true
|
|
|
|
expect(@email.text?).to.equal false
|
|
|
|
|
|
|
|
it "should not have undefined in it", ->
|
|
|
|
@email.html.indexOf("undefined").should.equal -1
|
|
|
|
@email.subject.indexOf("undefined").should.equal -1
|
|
|
|
|
|
|
|
describe "projectInvite", ->
|
|
|
|
beforeEach ->
|
|
|
|
@opts =
|
|
|
|
to:"bob@bob.com"
|
|
|
|
first_name:"bob"
|
|
|
|
owner:
|
|
|
|
email:"sally@hally.com"
|
|
|
|
inviteUrl: "http://example.com/invite"
|
|
|
|
project:
|
|
|
|
url:"http://www.project.com"
|
|
|
|
name:"standard project"
|
|
|
|
@email = @EmailBuilder.buildEmail("projectInvite", @opts)
|
|
|
|
|
|
|
|
it 'should have html and text properties', ->
|
|
|
|
expect(@email.html?).to.equal true
|
|
|
|
expect(@email.text?).to.equal true
|
|
|
|
|
2014-03-04 13:10:06 -05:00
|
|
|
it "should not have undefined in it", ->
|
|
|
|
@email.html.indexOf("undefined").should.equal -1
|
|
|
|
@email.subject.indexOf("undefined").should.equal -1
|