showdown.helpers.js 761 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Created by Estevao on 27/01/2017.
  3. */
  4. var bootstrap = require('../bootstrap.js'),
  5. showdown = bootstrap.showdown;
  6. describe('encodeEmailAddress()', function () {
  7. 'use strict';
  8. var encoder = showdown.helper.encodeEmailAddress,
  9. 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. });