EmailBuilderTests.coffee 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. should = require('chai').should()
  2. SandboxedModule = require('sandboxed-module')
  3. assert = require('assert')
  4. path = require('path')
  5. sinon = require('sinon')
  6. modulePath = path.join __dirname, "../../../../app/js/Features/Email/EmailBuilder"
  7. expect = require("chai").expect
  8. _ = require('underscore')
  9. _.templateSettings =
  10. interpolate: /\{\{(.+?)\}\}/g
  11. describe "Email Templator ", ->
  12. beforeEach ->
  13. @settings = {}
  14. @EmailBuilder = SandboxedModule.require modulePath, requires:
  15. "settings-sharelatex":@settings
  16. "logger-sharelatex": log:->
  17. describe "welcomeEmail", ->
  18. beforeEach ->
  19. @opts =
  20. to:"bob@bob.com"
  21. first_name:"bob"
  22. @email = @EmailBuilder.buildEmail("welcome", @opts)
  23. it "should insert the first_name into the template", ->
  24. @email.html.indexOf(@opts.first_name).should.not.equal -1
  25. it "should not have undefined in it", ->
  26. @email.html.indexOf("undefined").should.equal -1
  27. describe "projectSharedWithYou", ->
  28. beforeEach ->
  29. @opts =
  30. to:"bob@bob.com"
  31. first_name:"bob"
  32. owner:
  33. email:"sally@hally.com"
  34. project:
  35. url:"http://www.project.com"
  36. name:"standard project"
  37. @email = @EmailBuilder.buildEmail("projectSharedWithYou", @opts)
  38. it "should insert the owner email into the template", ->
  39. @email.html.indexOf(@opts.owner.email).should.not.equal -1
  40. @email.subject.indexOf(@opts.owner.email).should.not.equal -1
  41. it "should not have undefined in it", ->
  42. @email.html.indexOf("undefined").should.equal -1
  43. @email.subject.indexOf("undefined").should.equal -1