2017-01-28 03:03:37 +08:00
|
|
|
/**
|
|
|
|
* Created by Estevao on 27/01/2017.
|
|
|
|
*/
|
|
|
|
var bootstrap = require('../bootstrap.js'),
|
2017-01-28 06:07:55 +08:00
|
|
|
showdown = bootstrap.showdown;
|
2017-01-28 03:03:37 +08:00
|
|
|
|
2017-01-28 06:07:55 +08:00
|
|
|
describe('encodeEmailAddress()', function () {
|
2017-01-28 03:03:37 +08:00
|
|
|
'use strict';
|
2017-01-28 06:07:55 +08:00
|
|
|
var encoder = showdown.helper.encodeEmailAddress,
|
|
|
|
email = 'foobar@example.com',
|
2017-01-28 03:03:37 +08:00
|
|
|
encodedEmail = encoder(email);
|
|
|
|
|
|
|
|
it('should encode email', function () {
|
|
|
|
encodedEmail.should.not.equal(email);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should decode to original email', function () {
|
|
|
|
var decodedEmail = encodedEmail.replace(/&#(.+?);/g, function (wm, cc) {
|
|
|
|
if (cc.charAt(0) === 'x') {
|
|
|
|
//hex
|
|
|
|
return String.fromCharCode('0' + cc);
|
|
|
|
} else {
|
|
|
|
//dec
|
|
|
|
return String.fromCharCode(cc);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
decodedEmail.should.equal(email);
|
|
|
|
});
|
|
|
|
});
|