Skip to content
This repository
Browse code

add unit tests for linkTextWithEntity()

  • Loading branch information...
commit fcd597ec28ce2cefac731de6d5def9138398e3a4 1 parent b4bbc0d
Keita Fujii authored

Showing 1 changed file with 38 additions and 0 deletions. Show diff stats Hide diff stats

  1. 38  test/tests.js
38  test/tests.js
@@ -191,6 +191,44 @@ test("twttr.txt.autolink", function() {
191 191
       "Autolink hashtag/mentionURL w/ Supplementary character");
192 192
 });
193 193
 
  194
+test("twttr.txt.linkTextWithEntity", function() {
  195
+  var result = twttr.txt.linkTextWithEntity({
  196
+    "url": "http://t.co/abcde",
  197
+    "display_url": "twitter.com",
  198
+    "expanded_url": "http://twitter.com/"},
  199
+    {invisibleTagAttrs: "class='invisible'"});
  200
+  same(result,
  201
+      "<span class='tco-ellipsis'><span class='invisible'>&nbsp;</span></span><span class='invisible'>http://</span><span class='js-display-url'>twitter.com</span><span class='invisible'>/</span><span class='tco-ellipsis'><span class='invisible'>&nbsp;</span></span>",
  202
+      "Entire display_url is in expanded_url");
  203
+
  204
+  result = twttr.txt.linkTextWithEntity({
  205
+    "url": "http://t.co/abcde",
  206
+    "display_url": "twitter.com…",
  207
+    "expanded_url": "http://twitter.com/abcdefg"},
  208
+    {invisibleTagAttrs: "class='invisible'"});
  209
+  same(result,
  210
+      "<span class='tco-ellipsis'><span class='invisible'>&nbsp;</span></span><span class='invisible'>http://</span><span class='js-display-url'>twitter.com</span><span class='invisible'>/abcdefg</span><span class='tco-ellipsis'><span class='invisible'>&nbsp;</span>…</span>",
  211
+      "display_url ends with …");
  212
+
  213
+  result = twttr.txt.linkTextWithEntity({
  214
+    "url": "http://t.co/abcde",
  215
+    "display_url": "…tter.com/abcdefg",
  216
+    "expanded_url": "http://twitter.com/abcdefg"},
  217
+    {invisibleTagAttrs: "class='invisible'"});
  218
+  same(result,
  219
+      "<span class='tco-ellipsis'>…<span class='invisible'>&nbsp;</span></span><span class='invisible'>http://twi</span><span class='js-display-url'>tter.com/abcdefg</span><span class='invisible'></span><span class='tco-ellipsis'><span class='invisible'>&nbsp;</span></span>",
  220
+      "display_url begins with …");
  221
+
  222
+  result = twttr.txt.linkTextWithEntity({
  223
+    "url": "http://t.co/abcde",
  224
+    "display_url": "pic.twitter.com/xyz",
  225
+    "expanded_url": "http://twitter.com/foo/statuses/123/photo/1"},
  226
+    {invisibleTagAttrs: "class='invisible'"});
  227
+  same(result,
  228
+      "pic.twitter.com/xyz",
  229
+      "display_url and expanded_url are on different domains");
  230
+});
  231
+
194 232
 test("twttr.txt.extractMentionsOrListsWithIndices", function() {
195 233
   var invalid_chars = ['!', '@', '#', '$', '%', '&', '*'];
196 234
 

0 notes on commit fcd597e

Please sign in to comment.
Something went wrong with that request. Please try again.