Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
add test cases for $cashtag
Browse files Browse the repository at this point in the history
  • Loading branch information
keita committed May 4, 2012
1 parent a653afa commit d8b671b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
13 changes: 13 additions & 0 deletions autolink.yml
Expand Up @@ -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."
Expand Down Expand Up @@ -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>"
49 changes: 49 additions & 0 deletions extract.yml
Expand Up @@ -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]

0 comments on commit d8b671b

Please sign in to comment.