mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
9.5 KiB
140 lines
9.5 KiB
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/qunit@2.19.4/qunit/qunit.css" type="text/css" media="screen" />
|
|
</head>
|
|
<body>
|
|
<div id="qunit"></div>
|
|
<div id="qunit-fixture"></div>
|
|
<script src="https://cdn.jsdelivr.net/npm/qunit@2.19.4/qunit/qunit.min.js"></script>
|
|
<script src="../joypixels.js"></script>
|
|
<script>
|
|
|
|
QUnit.module("toImage");
|
|
|
|
QUnit.test( "test toImage", function( assert ) {
|
|
assert.equal(joypixels.toImage("Hello world! ๐ :smile:"), 'Hello world! <img class="joypixels" alt="๐" title=":smile:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f604.png"/> <img class="joypixels" alt="๐" title=":smile:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f604.png"/>');
|
|
});
|
|
|
|
QUnit.test( "mixed ascii, regular unicode and duplicate emoji", function( assert ) {
|
|
assert.equal(joypixels.toImage(":alien: is ๐ฝ and ์ is not :alien: or :alien: also :randomy: is not emoji"), '<img class="joypixels" alt="๐ฝ" title=":alien:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f47d.png"/> is <img class="joypixels" alt="๐ฝ" title=":alien:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f47d.png"/> and ์ is not <img class="joypixels" alt="๐ฝ" title=":alien:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f47d.png"/> or <img class="joypixels" alt="๐ฝ" title=":alien:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f47d.png"/> also :randomy: is not emoji');
|
|
});
|
|
|
|
|
|
QUnit.module("unifyUnicode");
|
|
|
|
QUnit.test( "test unifyUnicode", function( assert ) {
|
|
assert.equal(joypixels.unifyUnicode("Hello world! ๐ :smile:"), 'Hello world! ๐ ๐');
|
|
});
|
|
|
|
QUnit.test( "mixed ascii, regular unicode and duplicate emoji", function( assert ) {
|
|
assert.equal(joypixels.unifyUnicode(":alien: is ๐ฝ and ์ is not :alien: or :alien: also :randomy: is not emoji"), '๐ฝ is ๐ฝ and ์ is not ๐ฝ or ๐ฝ also :randomy: is not emoji');
|
|
});
|
|
|
|
QUnit.test( "multiline emoji string", function( assert ) {
|
|
assert.equal(joypixels.unifyUnicode(":dancer:\
|
|
:dancer:"), '๐\
|
|
๐');
|
|
});
|
|
|
|
QUnit.test( "triple emoji string", function( assert ) {
|
|
assert.equal(joypixels.unifyUnicode(":dancer::dancer::alien:"), '๐๐๐ฝ');
|
|
});
|
|
|
|
|
|
QUnit.module("shortnameToUnicode");
|
|
|
|
QUnit.test( "single unicode character conversion", function( assert ) {
|
|
assert.equal(joypixels.shortnameToUnicode("Hello world! ๐ :smile:"), 'Hello world! ๐ ๐');
|
|
});
|
|
|
|
QUnit.test( "shortname at start of sentence with apostrophe", function( assert ) {
|
|
assert.equal(joypixels.shortnameToUnicode(":snail:'s are cool!"), '๐\'s are cool!');
|
|
});
|
|
|
|
QUnit.test( "shortname shares a colon", function( assert ) {
|
|
assert.equal(joypixels.shortnameToUnicode(":invalid:snail:"), ':invalid๐');
|
|
});
|
|
|
|
QUnit.test( "mixed ascii, regular unicode and duplicate emoji", function( assert ) {
|
|
assert.equal(joypixels.shortnameToUnicode(":alien: is ๐ฝ and ์ is not :alien: or :alien: also :randomy: is not emoji"), '๐ฝ is ๐ฝ and ์ is not ๐ฝ or ๐ฝ also :randomy: is not emoji');
|
|
});
|
|
|
|
QUnit.test( "multiline emoji string", function( assert ) {
|
|
assert.equal(joypixels.shortnameToUnicode(":dancer:\n:dancer:"), '๐\n๐');
|
|
});
|
|
|
|
QUnit.test( "triple emoji string", function( assert ) {
|
|
assert.equal(joypixels.shortnameToUnicode(":dancer::dancer::alien:"), '๐๐๐ฝ');
|
|
});
|
|
|
|
|
|
QUnit.module("shortnameToImage");
|
|
|
|
QUnit.test( "single shortname character conversion", function( assert ) {
|
|
assert.equal(joypixels.shortnameToImage("Hello world! ๐ :smile:"), 'Hello world! ๐ <img class="joypixels" alt="๐" title=":smile:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f604.png"/>');
|
|
});
|
|
|
|
QUnit.test( "shortname at start of sentence with apostrophe", function( assert ) {
|
|
assert.equal(joypixels.shortnameToImage(":snail:'s are cool!"), '<img class="joypixels" alt="๐" title=":snail:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f40c.png"/>\'s are cool!');
|
|
});
|
|
|
|
QUnit.test( "shortname shares a colon", function( assert ) {
|
|
assert.equal(joypixels.shortnameToImage(":invalid:snail:"), ':invalid<img class="joypixels" alt="๐" title=":snail:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f40c.png"/>');
|
|
});
|
|
|
|
QUnit.test( "mixed ascii, regular unicode and duplicate emoji", function( assert ) {
|
|
assert.equal(joypixels.shortnameToImage(":alien: is ๐ฝ and ์ is not :alien: or :alien: also :randomy: is not emoji"), '<img class="joypixels" alt="๐ฝ" title=":alien:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f47d.png"/> is ๐ฝ and ์ is not <img class="joypixels" alt="๐ฝ" title=":alien:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f47d.png"/> or <img class="joypixels" alt="๐ฝ" title=":alien:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f47d.png"/> also :randomy: is not emoji');
|
|
});
|
|
|
|
QUnit.test( "multiline emoji string", function( assert ) {
|
|
assert.equal(joypixels.shortnameToImage(":dancer:\n:dancer:"), '<img class="joypixels" alt="๐" title=":dancer:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f483.png"/>\n<img class="joypixels" alt="๐" title=":dancer:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f483.png"/>');
|
|
});
|
|
|
|
QUnit.test( "triple emoji string", function( assert ) {
|
|
assert.equal(joypixels.shortnameToImage(":dancer::dancer::alien:"), '<img class="joypixels" alt="๐" title=":dancer:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f483.png"/><img class="joypixels" alt="๐" title=":dancer:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f483.png"/><img class="joypixels" alt="๐ฝ" title=":alien:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f47d.png"/>');
|
|
});
|
|
|
|
|
|
QUnit.module("toShort");
|
|
|
|
QUnit.test( "single unicode character conversion", function( assert ) {
|
|
assert.equal(joypixels.toShort("Hello world! ๐ :smile:"), 'Hello world! :smile: :smile:');
|
|
});
|
|
|
|
QUnit.test( "mixed ascii, regular unicode and duplicate emoji", function( assert ) {
|
|
assert.equal(joypixels.toShort("๐ฝ is not :alien: and ์ is not ๐ฝ or ๐ฝ"), ':alien: is not :alien: and ์ is not :alien: or :alien:');
|
|
});
|
|
|
|
QUnit.test( "multiline emoji string", function( assert ) {
|
|
assert.equal(joypixels.toShort("๐\n๐"), ':dancer:\n:dancer:');
|
|
});
|
|
|
|
QUnit.test( "alias vs. canonical", function( assert ) {
|
|
assert.equal(joypixels.toShort("๐ฏ๐ต ใฉใใใใใใจใ"), ':flag_jp: ใฉใใใใใใจใ');
|
|
});
|
|
|
|
QUnit.test( "unicode character conversion within excluded tag", function( assert ) {
|
|
assert.equal(joypixels.toShort("<div>๐</div>"), '<div>:smile:</div>');
|
|
});
|
|
|
|
|
|
QUnit.module("toImage");
|
|
|
|
QUnit.test( "single character shortname conversion", function( assert ) {
|
|
assert.equal(joypixels.toImage("Hello world! ๐ :smile:"), 'Hello world! <img class="joypixels" alt="๐" title=":smile:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f604.png"/> <img class="joypixels" alt="๐" title=":smile:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f604.png"/>');
|
|
});
|
|
|
|
QUnit.test( "shortname shares a colon", function( assert ) {
|
|
assert.equal(joypixels.toImage(":invalid:snail:"), ':invalid<img class="joypixels" alt="๐" title=":snail:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f40c.png"/>');
|
|
});
|
|
|
|
QUnit.test( "single unicode character conversion", function( assert ) {
|
|
assert.equal(joypixels.toImage("๐"), '<img class="joypixels" alt="๐" title=":snail:" src="https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/1f40c.png"/>');
|
|
});
|
|
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|