EmailBuilderTests.coffee 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 text component', ->
  32. expect(@email.html?).to.equal true
  33. expect(@email.text?).to.equal false
  34. it "should not have undefined in it", ->
  35. @email.html.indexOf("undefined").should.equal -1
  36. @email.subject.indexOf("undefined").should.equal -1
  37. describe "projectInvite", ->
  38. beforeEach ->
  39. @opts =
  40. to:"bob@bob.com"
  41. first_name:"bob"
  42. owner:
  43. email:"sally@hally.com"
  44. inviteUrl: "http://example.com/invite"
  45. project:
  46. url:"http://www.project.com"
  47. name:"standard project"
  48. @email = @EmailBuilder.buildEmail("projectInvite", @opts)
  49. it 'should have html and text properties', ->
  50. expect(@email.html?).to.equal true
  51. expect(@email.text?).to.equal true
  52. it "should not have undefined in it", ->
  53. @email.html.indexOf("undefined").should.equal -1
  54. @email.subject.indexOf("undefined").should.equal -1