mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 19:34:26 +00:00
53 lines
1.5 KiB
CoffeeScript
53 lines
1.5 KiB
CoffeeScript
should = require('chai').should()
|
|
SandboxedModule = require('sandboxed-module')
|
|
assert = require('assert')
|
|
path = require('path')
|
|
sinon = require('sinon')
|
|
modulePath = path.join __dirname, "../../../../app/js/Features/Email/EmailBuilder"
|
|
expect = require("chai").expect
|
|
_ = require('underscore')
|
|
_.templateSettings =
|
|
interpolate: /\{\{(.+?)\}\}/g
|
|
|
|
describe "Email Templator ", ->
|
|
|
|
beforeEach ->
|
|
|
|
@settings = {}
|
|
@EmailBuilder = SandboxedModule.require modulePath, requires:
|
|
"settings-sharelatex":@settings
|
|
"logger-sharelatex": log:->
|
|
|
|
describe "welcomeEmail", ->
|
|
|
|
beforeEach ->
|
|
@opts =
|
|
to:"bob@bob.com"
|
|
first_name:"bob"
|
|
@email = @EmailBuilder.buildEmail("welcome", @opts)
|
|
|
|
it "should insert the first_name into the template", ->
|
|
@email.html.indexOf(@opts.first_name).should.not.equal -1
|
|
|
|
it "should not have undefined in it", ->
|
|
@email.html.indexOf("undefined").should.equal -1
|
|
|
|
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"
|
|
@email = @EmailBuilder.buildEmail("projectSharedWithYou", @opts)
|
|
|
|
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
|
|
|
|
it "should not have undefined in it", ->
|
|
@email.html.indexOf("undefined").should.equal -1
|
|
@email.subject.indexOf("undefined").should.equal -1
|