showdown.helpers.js 756 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Created by Estevao on 27/01/2017.
  3. */
  4. var bootstrap = require('../bootstrap.js'),
  5. showdown = bootstrap.showdown,
  6. encoder = showdown.helper.encodeEmailAddress;
  7. describe('encodeEmailAddress', function () {
  8. 'use strict';
  9. var email = 'foobar@example.com',
  10. encodedEmail = encoder(email);
  11. it('should encode email', function () {
  12. encodedEmail.should.not.equal(email);
  13. });
  14. it('should decode to original email', function () {
  15. var decodedEmail = encodedEmail.replace(/&#(.+?);/g, function (wm, cc) {
  16. if (cc.charAt(0) === 'x') {
  17. //hex
  18. return String.fromCharCode('0' + cc);
  19. } else {
  20. //dec
  21. return String.fromCharCode(cc);
  22. }
  23. });
  24. decodedEmail.should.equal(email);
  25. });
  26. });