<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/qunit/1.14.0/qunit.css" type="text/css" media="screen" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="http://cdn.jsdelivr.net/qunit/1.14.0/qunit.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/6.6/png/unicode/64/1f604.png\"/> <img class=\"joypixels\" alt=\"π\" title=\":smile:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/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/6.6/png/unicode/64/1f47d.png\"/> is <img class=\"joypixels\" alt=\"π½\" title=\":alien:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/1f47d.png\"/> and μ is not <img class=\"joypixels\" alt=\"π½\" title=\":alien:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/1f47d.png\"/> or <img class=\"joypixels\" alt=\"π½\" title=\":alien:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/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/6.6/png/unicode/64/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/6.6/png/unicode/64/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/6.6/png/unicode/64/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/6.6/png/unicode/64/1f47d.png\"/> is π½ and μ is not <img class=\"joypixels\" alt=\"π½\" title=\":alien:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/1f47d.png\"/> or <img class=\"joypixels\" alt=\"π½\" title=\":alien:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/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/6.6/png/unicode/64/1f483.png\"/>\n<img class=\"joypixels\" alt=\"π\" title=\":dancer:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/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/6.6/png/unicode/64/1f483.png\"/><img class=\"joypixels\" alt=\"π\" title=\":dancer:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/1f483.png\"/><img class=\"joypixels\" alt=\"π½\" title=\":alien:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/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/6.6/png/unicode/64/1f604.png\"/> <img class=\"joypixels\" alt=\"π\" title=\":smile:\" src=\"https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/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/6.6/png/unicode/64/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/6.6/png/unicode/64/1f40c.png\"/>");
});
</script>
</body>
</html>