Commit 72345d6c4e501b0d3ba473a1879c34a7fca15789
- Diff rendering mode:
- inline
- side by side
tests/unit.rb
(24 / 9)
|   | |||
| 29 | 29 | end | |
| 30 | 30 | ||
| 31 | 31 | should "correctly parse urls with pages with ? in the url" do | |
| 32 | assert_equal "<a href=\"https://www.google.com/?whatever.com\">https://www.google.com/?whatever.com</a>", linkify("https://www.google.com/?whatever.com") | ||
| 32 | assert_equal | ||
| 33 | "<a href=\"https://www.google.com/?whatever.com\">https://www.google.com/?whatever.com</a>", | ||
| 34 | linkify("https://www.google.com/?whatever.com") | ||
| 33 | 35 | end | |
| 34 | 36 | ||
| 35 | 37 | should "correctly parse urls ending with a '.'" do | |
| 36 | assert_equal "blah blah <a href=\"https://www.google.com/\">https://www.google.com/</a>. Blah", linkify("blah blah https://www.google.com/. Blah") | ||
| 38 | assert_equal | ||
| 39 | "blah blah <a href=\"https://www.google.com/\">https://www.google.com/</a>. Blah", | ||
| 40 | linkify("blah blah https://www.google.com/. Blah") | ||
| 37 | 41 | end | |
| 38 | 42 | ||
| 39 | 43 | should "correctly parse urls ending with a '.' at the end of a string" do | |
| 40 | assert_equal "blah blah <a href=\"https://www.google.com/\">https://www.google.com/</a>.", linkify("blah blah https://www.google.com/.") | ||
| 44 | assert_equal | ||
| 45 | "blah blah <a href=\"https://www.google.com/\">https://www.google.com/</a>.", | ||
| 46 | linkify("blah blah https://www.google.com/.") | ||
| 41 | 47 | end | |
| 42 | 48 | ||
| 43 | 49 | should "correctly parse urls containing #." do | |
| 44 | assert_equal "<a href=\"https://www.google.com/#anchor\">https://www.google.com/#anchor</a>", linkify("https://www.google.com/#anchor") | ||
| 50 | assert_equal | ||
| 51 | "<a href=\"https://www.google.com/#anchor\">https://www.google.com/#anchor</a>", | ||
| 52 | linkify("https://www.google.com/#anchor") | ||
| 45 | 53 | end | |
| 46 | 54 | ||
| 47 | 55 | should "correctly parse urls containing +." do | |
| 48 | assert_equal "<a href=\"https://www.google.com/+stuff\">https://www.google.com/+stuff</a>", linkify("https://www.google.com/+stuff") | ||
| 56 | assert_equal | ||
| 57 | "<a href=\"https://www.google.com/+stuff\">https://www.google.com/+stuff</a>", | ||
| 58 | linkify("https://www.google.com/+stuff") | ||
| 49 | 59 | end | |
| 50 | 60 | ||
| 51 | 61 | should "correctly parse urls containing -" do | |
| 52 | assert_equal "<a href=\"http://www.hypebot.com/hypebot/2009/06/walmart-shutting-down-drm-download-servers.html\">http://www.hypebot.com/hypebot/2009/06/walmart-shutting-down-drm-download-servers.html</a>", linkify("http://www.hypebot.com/hypebot/2009/06/walmart-shutting-down-drm-download-servers.html") | ||
| 62 | assert_equal | ||
| 63 | "<a href=\"http://www.hypebot.com/hypebot/2009/06/walmart-shutting-down-drm-download-servers.html\">http://www.hypebot.com/hypebot/2009/06/walmart-shutting-down-drm-download-servers.html</a>", | ||
| 64 | linkify("http://www.hypebot.com/hypebot/2009/06/walmart-shutting-down-drm-download-servers.html") | ||
| 53 | 65 | end | |
| 54 | 66 | ||
| 55 | 67 | should "correctly parse urls ending with ':'" do | |
| 56 | assert_equal "some stuff <a href=\"http://google.com/whatever\">http://google.com/whatever</a>: stuff", linkify("some stuff http://google.com/whatever: stuff") | ||
| 68 | assert_equal | ||
| 69 | "some stuff <a href=\"http://google.com/whatever\">http://google.com/whatever</a>: stuff", | ||
| 70 | linkify("some stuff http://google.com/whatever: stuff") | ||
| 57 | 71 | end | |
| 58 | 72 | ||
| 59 | 73 | should "correctly parse urls ending with ':' at the end of the string" do | |
| 60 | assert_equal "some stuff <a href=\"http://google.com/whatever\">http://google.com/whatever</a>:", linkify("some stuff http://google.com/whatever:") | ||
| 74 | assert_equal | ||
| 75 | "some stuff <a href=\"http://google.com/whatever\">http://google.com/whatever</a>:", | ||
| 76 | linkify("some stuff http://google.com/whatever:") | ||
| 61 | 77 | end | |
| 62 | |||
| 63 | 78 | end | |
| 64 | 79 | end |

