From a2b1680434b1ac7799872c10215bb5fa4e6ac0c5 Mon Sep 17 00:00:00 2001 From: Tim Haines Date: Thu, 1 May 2014 11:14:15 -0700 Subject: [PATCH] Add failing test that shows inconsistent result from autoLinkWithJSON --- test/tests.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/tests.js b/test/tests.js index 175dbc6..e449db8 100644 --- a/test/tests.js +++ b/test/tests.js @@ -307,3 +307,52 @@ test("twttr.txt.extractUrls", function() { equal(twttr.txt.extractUrls(message_with_hyphenated_url)[0], "hyphenated-url.com", "Should extract full url with hyphen."); equal(twttr.txt.extractUrls(message_with_www_hyphenated_url)[0], "www.123-hyphenated-url.com", "Should extract full url with hyphen."); }); + +test("consistent result from autoLinkWithJSON", function(){ + // This is based on tweet 461744655009591296 + var tweet = "@rdioapi @affan_imran 🎉 We just came up with someone's hack day project at @rdio."; + var entities = { + "hashtags": [], + "symbols": [], + "urls": [], + "user_mentions": [ + { + "screen_name": "rdioapi", + "name": "Rdio API", + "id": 161493716, + "id_str": "161493716", + "indices": [ + 0, + 8 + ] + }, + { + "screen_name": "affan_imran", + "name": "Affan I", + "id": 18968588, + "id_str": "18968588", + "indices": [ + 9, + 21 + ] + }, + { + "screen_name": "Rdio", + "name": "Rdio", + "id": 54205414, + "id_str": "54205414", + "indices": [ + 75, + 80 + ] + } + ] + }; + + var expectedResult = "@rdioapi @affan_imran 🎉 We just came up with someone's hack day project at @Rdio."; + + equal(twttr.txt.autoLinkWithJSON(tweet, entities), expectedResult); + // Currently this second invocation triggers a failure as it + // produces a different result. + equal(twttr.txt.autoLinkWithJSON(tweet, entities), expectedResult); +});