From 3123cfe1765bb0499da9bd22e6befeb738a99d80 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Tue, 2 Dec 2014 17:09:36 +0000 Subject: [PATCH] added extra invariants and invalid chars tests --- test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test.js b/test.js index 750b1680..b73db642 100644 --- a/test.js +++ b/test.js @@ -391,4 +391,26 @@ wru.test([{ }) ); } +},{ + name: 'invalid variants and chars', + test: function () { + var div = document.createElement('div'); + var img; + div.innerHTML = twemoji.parse('"\u2b1c\uFE0F"'); + img = div.getElementsByTagName('img')[0]; + wru.assert('correct img.alt 1', img.alt === "\u2b1c\uFE0F"); + wru.assert('correct img.src 1', img.src.slice(-8) === '2b1c.png'); + // other variants should be ignored + div.innerHTML = twemoji.parse('"\u2b1c\uFE00"'); + img = div.getElementsByTagName('img')[0]; + wru.assert('correct img.alt 2', img.alt === "\u2b1c"); + wru.assert('correct img.src 2', img.src.slice(-8) === '2b1c.png'); + div.removeChild(img); + // the variant without meanings are still there + div.innerHTML === '"\uFE00"'; + // when there is a trailing \uFE0E there should be no image + div.innerHTML = twemoji.parse('"\u2b1c\uFE0E"'); + wru.assert('correct length', div.getElementsByTagName('img').length === 0); + wru.assert('expected html', div.innerHTML === '"\u2b1c\uFE0E"'); + } }]); \ No newline at end of file