mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(helpers): update octocat emoji image location; add tests
This commit is contained in:
parent
f9d9705d3c
commit
5544e4d995
|
@ -1710,6 +1710,6 @@ showdown.helper.emojis = {
|
|||
'zzz':'\ud83d\udca4',
|
||||
|
||||
/* special emojis :P */
|
||||
'octocat': '<img width="20" height="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">',
|
||||
'octocat': '<img width="20" height="20" align="absmiddle" src="https://github.githubassets.com/images/icons/emoji/octocat.png">',
|
||||
'showdown': '<img width="20" height="20" align="absmiddle" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAS1BMVEX///8jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS3b1q3b1q3b1q3b1q3b1q3b1q3b1q3b1q0565CIAAAAGXRSTlMAQHCAYCCw/+DQwPCQUBAwoHCAEP+wwFBgS2fvBgAAAUZJREFUeAHs1cGy7BAUheFFsEDw/k97VTq3T6ge2EmdM+pvrP6Iwd74XV9Kb52xuMU4/uc1YNgZLFOeV8FGdhGrNk5SEgUyPxAEdj4LlMRDyhVAMVEa2M7TBSeVZAFPdqHgzSZJwPKgcLFLAooHDJo4EDCw4gAtBoJA5UFj4Ng5LOGLwVXZuoIlji/jeQHFk7+baHxrCjeUwB9+s88KndvlhcyBN5BSkYNQIVVb4pV+Npm7hhuKDs/uMP5KxT3WzSNNLIuuoDpMmuAVMruMSeDyQBi24DTr43LAY7ILA1QYaWkgfHzFthYYzg67SQsCbB8GhJUEGCtO9n0rSaCLxgJQjS/JSgMTg2eBDEHAJ+H350AsjYNYscrErgI2e/l+mdR967TCX/v6N0EhPECYCP0i+IAoYQOE8BogNhQMEMdrgAQWHaMAAGi5I5euoY9NAAAAAElFTkSuQmCC">'
|
||||
};
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<p>this is showdown's emoji <img width="20" height="20" align="absmiddle" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAS1BMVEX///8jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS3b1q3b1q3b1q3b1q3b1q3b1q3b1q3b1q0565CIAAAAGXRSTlMAQHCAYCCw/+DQwPCQUBAwoHCAEP+wwFBgS2fvBgAAAUZJREFUeAHs1cGy7BAUheFFsEDw/k97VTq3T6ge2EmdM+pvrP6Iwd74XV9Kb52xuMU4/uc1YNgZLFOeV8FGdhGrNk5SEgUyPxAEdj4LlMRDyhVAMVEa2M7TBSeVZAFPdqHgzSZJwPKgcLFLAooHDJo4EDCw4gAtBoJA5UFj4Ng5LOGLwVXZuoIlji/jeQHFk7+baHxrCjeUwB9+s88KndvlhcyBN5BSkYNQIVVb4pV+Npm7hhuKDs/uMP5KxT3WzSNNLIuuoDpMmuAVMruMSeDyQBi24DTr43LAY7ILA1QYaWkgfHzFthYYzg67SQsCbB8GhJUEGCtO9n0rSaCLxgJQjS/JSgMTg2eBDEHAJ+H350AsjYNYscrErgI2e/l+mdR967TCX/v6N0EhPECYCP0i+IAoYQOE8BogNhQMEMdrgAQWHaMAAGi5I5euoY9NAAAAAElFTkSuQmCC"></p>
|
||||
<p>and this is github's emoji <img width="20" height="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png"></p>
|
||||
<p>and this is github's emoji <img width="20" height="20" align="absmiddle" src="https://github.githubassets.com/images/icons/emoji/octocat.png"></p>
|
||||
|
|
|
@ -18,7 +18,10 @@ var bootstrap = require('./makehtml.bootstrap.js'),
|
|||
//literalMidWordAsterisksSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/literalMidWordAsterisks/'),
|
||||
completeHTMLOutputSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/completeHTMLOutput/'),
|
||||
metadataSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/metadata/'),
|
||||
splitAdjacentBlockquotesSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/splitAdjacentBlockquotes/');
|
||||
splitAdjacentBlockquotesSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/splitAdjacentBlockquotes/'),
|
||||
http = require('http'),
|
||||
https = require('https'),
|
||||
expect = require('chai').expect;
|
||||
|
||||
describe('makeHtml() features testsuite', function () {
|
||||
'use strict';
|
||||
|
@ -190,7 +193,31 @@ describe('makeHtml() features testsuite', function () {
|
|||
/** test emojis support **/
|
||||
describe('emojis support', function () {
|
||||
var converter,
|
||||
suite = emojisSuite;
|
||||
suite = emojisSuite,
|
||||
imgSrcRegexp = /<img[^>]+src=("https?:\/\/[^"]+"|'https?:\/\/[^']+')/g;
|
||||
|
||||
function testImageUrlExists (imgUrl) {
|
||||
// Strip the quotes
|
||||
imgUrl = imgUrl.substr(0, imgUrl.length - 1).substr(1);
|
||||
return function (done) {
|
||||
(imgUrl.startsWith('http://') ? http : https).get(imgUrl, function (res) {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
// Make sure we get some data and that it's a png
|
||||
expect(parseInt(res.headers['content-length'], 10)).to.be.above(0);
|
||||
expect(res.headers['content-type']).to.equal('image/png');
|
||||
|
||||
// Discard the data (but fetch it)
|
||||
res.on('data', function () {});
|
||||
|
||||
res.on('end', function () {
|
||||
done();
|
||||
});
|
||||
}).on('error', function (e) {
|
||||
throw e;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
for (var i = 0; i < suite.length; ++i) {
|
||||
if (suite[i].name === 'simplifiedautolinks') {
|
||||
converter = new showdown.Converter({emoji: true, simplifiedAutoLink: true});
|
||||
|
@ -199,6 +226,11 @@ describe('makeHtml() features testsuite', function () {
|
|||
}
|
||||
|
||||
it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter));
|
||||
|
||||
var imgUrl = imgSrcRegexp.exec(suite[i].expected);
|
||||
if (imgUrl) {
|
||||
it('should use a working emoji URL', testImageUrlExists(imgUrl[1]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user