Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add test cases for $cashtag

  • Loading branch information...
commit d8b671b0f889e9de80f965cf7b22f5643380ab31 1 parent a653afa
@keitaf keitaf authored
Showing with 62 additions and 0 deletions.
  1. +13 −0 autolink.yml
  2. +49 −0 extract.yml
View
13 autolink.yml
@@ -672,6 +672,15 @@ tests:
text: "$https://twitter.com $twitter.com $http://t.co/abcde $t.co/abcde $t.co $TVI.CA $RBS.CA"
expected: "$https://twitter.com $twitter.com $http://t.co/abcde $t.co/abcde $t.co $TVI.CA $RBS.CA"
+ cashtags:
+ - description: "Autolink a cashtag"
+ text: "$STOCK"
+ expected: "<a href=\"https://twitter.com/#!/search?q=%24STOCK\" title=\"$STOCK\" class=\"tweet-url cashtag\">$STOCK</a>"
+
+ - description: "Autolink a cashtag in text"
+ text: "Text $STOCK text $symbol text"
+ expected: "Text <a href=\"https://twitter.com/#!/search?q=%24STOCK\" title=\"$STOCK\" class=\"tweet-url cashtag\">$STOCK</a> text <a href=\"https://twitter.com/#!/search?q=%24symbol\" title=\"$symbol\" class=\"tweet-url cashtag\">$symbol</a> text"
+
all:
- description: "Autolink all does not break on URL with @"
text: "http://www.flickr.com/photos/29674651@N00/4382024406 if you know what's good for you."
@@ -708,3 +717,7 @@ tests:
- description: "Autolink @mention if followed by . and TLD"
text: "@twitter.com @twitter.co.jp"
expected: "@<a class=\"tweet-url username\" href=\"https://twitter.com/twitter\">twitter</a>.com @<a class=\"tweet-url username\" href=\"https://twitter.com/twitter\">twitter</a>.co.jp"
+
+ - description: "Autolink a cashtag"
+ text: "$STOCK"
+ expected: "<a href=\"https://twitter.com/#!/search?q=%24STOCK\" title=\"$STOCK\" class=\"tweet-url cashtag\">$STOCK</a>"
View
49 extract.yml
@@ -798,3 +798,52 @@ tests:
- hashtag: "русский"
indices: [33, 41]
+ cashtags:
+ - description: "Extract cashtags"
+ text: "Example cashtags: $TEST $Stock $symbol"
+ expected: ["TEST", "Stock", "symbol"]
+
+ - description: "Extract cashtags with . or _"
+ text: "Example cashtags: $TEST.T $test.tt $Stock_X $symbol_ab"
+ expected: ["TEST.T", "test.tt", "Stock_X", "symbol_ab"]
+
+ - description: "Do not extract cashtags if they contain numbers"
+ text: "$123 $test123 $TE123ST"
+ expected: []
+
+ - description: "Do not extract cashtags with non-ASCII characters"
+ text: "$ストック $株"
+ expected: []
+
+ - description: "Do not extract cashtags with punctuations"
+ text: "$ $. $- $@ $! $() $+"
+ expected: []
+
+ - description: "Do not include trailing . or _"
+ text: "$TEST. $TEST_"
+ expected: ["TEST", "TEST"]
+
+ - description: "Do not extract cashtags if there is no space before $"
+ text: "$OK$NG$BAD text$NO .$NG $$NG"
+ expected: ["OK"]
+
+ - description: "Do not extract too long cashtags"
+ text: "$CashtagMustBeLessThanSixCharacter"
+ expected: []
+
+ cashtags_with_indices:
+ - description: "Extract cashtags"
+ text: "Example: $TEST $symbol test"
+ expected:
+ - cashtag: "TEST"
+ indices: [9, 14]
+ - cashtag: "symbol"
+ indices: [15, 22]
+
+ - description: "Extract cashtags with . or _"
+ text: "Example: $TEST.T test $symbol_ab end"
+ expected:
+ - cashtag: "TEST.T"
+ indices: [9, 16]
+ - cashtag: "symbol_ab"
+ indices: [22, 32]
Please sign in to comment.
Something went wrong with that request. Please try again.