mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
31 lines
756 B
JavaScript
31 lines
756 B
JavaScript
|
/**
|
||
|
* Created by Estevao on 27/01/2017.
|
||
|
*/
|
||
|
|
||
|
var bootstrap = require('../bootstrap.js'),
|
||
|
showdown = bootstrap.showdown,
|
||
|
encoder = showdown.helper.encodeEmailAddress;
|
||
|
|
||
|
describe('encodeEmailAddress', function () {
|
||
|
'use strict';
|
||
|
var email = 'foobar@example.com',
|
||
|
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);
|
||
|
});
|
||
|
});
|