EmailBuilderTests.coffee 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 =
  14. appName: "testApp"
  15. brandPrefix: ''
  16. @EmailBuilder = SandboxedModule.require modulePath, requires:
  17. "settings-sharelatex":@settings
  18. "logger-sharelatex": log:->
  19. describe "projectInvite", ->
  20. beforeEach ->
  21. @opts =
  22. to:"bob@bob.com"
  23. first_name:"bob"
  24. owner:
  25. email:"sally@hally.com"
  26. inviteUrl: "http://example.com/invite"
  27. project:
  28. url:"http://www.project.com"
  29. name:"standard project"
  30. @email = @EmailBuilder.buildEmail("projectInvite", @opts)
  31. it 'should have html and text properties', ->
  32. expect(@email.html?).to.equal true
  33. expect(@email.text?).to.equal true
  34. it "should not have undefined in it", ->
  35. @email.html.indexOf("undefined").should.equal -1
  36. @email.subject.indexOf("undefined").should.equal -1