EmailMessageHelperTests.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. const SandboxedModule = require('sandboxed-module')
  2. const path = require('path')
  3. const { expect } = require('chai')
  4. const MODULE_PATH = path.join(
  5. __dirname,
  6. '../../../../app/src/Features/Email/EmailMessageHelper'
  7. )
  8. describe('EmailMessageHelper', function () {
  9. beforeEach(function () {
  10. this.EmailMessageHelper = SandboxedModule.require(MODULE_PATH, {})
  11. })
  12. describe('cleanHTML', function () {
  13. beforeEach(function () {
  14. this.text = 'a message'
  15. this.span = `<span style="text-align:center">${this.text}</span>`
  16. this.fullMessage = `${this.span}<div></div>`
  17. })
  18. it('should remove HTML for plainText version', function () {
  19. const processed = this.EmailMessageHelper.cleanHTML(
  20. this.fullMessage,
  21. true
  22. )
  23. expect(processed).to.equal(this.text)
  24. })
  25. it('should keep HTML for HTML version but remove tags not allowed', function () {
  26. const processed = this.EmailMessageHelper.cleanHTML(
  27. this.fullMessage,
  28. false
  29. )
  30. expect(processed).to.equal(this.span)
  31. })
  32. })
  33. })