EmailBuilderTests.coffee 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 "EmailBuilder", ->
  12. beforeEach ->
  13. @settings = appName: "testApp"
  14. @EmailBuilder = SandboxedModule.require modulePath, requires:
  15. "settings-sharelatex":@settings
  16. "logger-sharelatex": log:->
  17. describe "projectSharedWithYou", ->
  18. beforeEach ->
  19. @opts =
  20. to:"bob@bob.com"
  21. first_name:"bob"
  22. owner:
  23. email:"sally@hally.com"
  24. project:
  25. url:"http://www.project.com"
  26. name:"standard project"
  27. @email = @EmailBuilder.buildEmail("projectSharedWithYou", @opts)
  28. it "should insert the owner email into the template", ->
  29. @email.html.indexOf(@opts.owner.email).should.not.equal -1
  30. @email.subject.indexOf(@opts.owner.email).should.not.equal -1
  31. it "should not have undefined in it", ->
  32. @email.html.indexOf("undefined").should.equal -1
  33. @email.subject.indexOf("undefined").should.equal -1