| 1 | use strict; |
|---|
| 2 | use warnings; |
|---|
| 3 | use Test::Base; |
|---|
| 4 | use App::Mobirc::Plugin::MessageBodyFilter::Clickable; |
|---|
| 5 | |
|---|
| 6 | plan tests => 1*blocks; |
|---|
| 7 | |
|---|
| 8 | filters { |
|---|
| 9 | input => ['yaml', 'clickable' ] |
|---|
| 10 | }; |
|---|
| 11 | |
|---|
| 12 | sub clickable { |
|---|
| 13 | my $x = shift; |
|---|
| 14 | App::Mobirc::Plugin::MessageBodyFilter::Clickable::process( $x->{text}, $x->{conf} ); |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | run_is input => 'expected'; |
|---|
| 18 | |
|---|
| 19 | __END__ |
|---|
| 20 | |
|---|
| 21 | === basic |
|---|
| 22 | --- input |
|---|
| 23 | text: http://d.hatena.ne.jp/ |
|---|
| 24 | conf: ~ |
|---|
| 25 | --- expected: <a href="http://d.hatena.ne.jp/" rel="nofollow" class="url">http://d.hatena.ne.jp/</a> |
|---|
| 26 | |
|---|
| 27 | === basic scheme restrict |
|---|
| 28 | --- input |
|---|
| 29 | text: http://d.hatena.ne.jp/ |
|---|
| 30 | conf: |
|---|
| 31 | accept_schemes: [mailto] |
|---|
| 32 | --- expected: http://d.hatena.ne.jp/ |
|---|
| 33 | |
|---|
| 34 | === basic with http_link_string |
|---|
| 35 | --- input |
|---|
| 36 | text: http://d.hatena.ne.jp/hatenachan/ |
|---|
| 37 | conf: |
|---|
| 38 | http_link_string: $host$path |
|---|
| 39 | --- expected: <a href="http://d.hatena.ne.jp/hatenachan/" rel="nofollow" class="url">d.hatena.ne.jp/hatenachan/</a> |
|---|
| 40 | |
|---|
| 41 | === tel |
|---|
| 42 | --- input |
|---|
| 43 | text: 000-0000-0000 |
|---|
| 44 | conf: ~ |
|---|
| 45 | --- expected: <a href="tel:00000000000" rel="nofollow" class="url">000-0000-0000</a> |
|---|
| 46 | |
|---|
| 47 | === tel with scheme |
|---|
| 48 | --- input |
|---|
| 49 | text: tel:000-0000-0000 |
|---|
| 50 | conf: ~ |
|---|
| 51 | --- expected: <a href="tel:00000000000" rel="nofollow" class="url">tel:000-0000-0000</a> |
|---|
| 52 | |
|---|
| 53 | === mailto |
|---|
| 54 | --- input |
|---|
| 55 | text: aaa@example.com |
|---|
| 56 | conf: ~ |
|---|
| 57 | --- expected: <a href="mailto:aaa@example.com" rel="nofollow" class="url">aaa@example.com</a> |
|---|
| 58 | |
|---|
| 59 | === mailto with scheme |
|---|
| 60 | --- input |
|---|
| 61 | text: mailto:aaa@example.com |
|---|
| 62 | conf: ~ |
|---|
| 63 | --- expected: <a href="mailto:aaa@example.com" rel="nofollow" class="url">mailto:aaa@example.com</a> |
|---|
| 64 | |
|---|
| 65 | === pocket hatena |
|---|
| 66 | --- input |
|---|
| 67 | text: http://d.hatena.ne.jp/ |
|---|
| 68 | conf: |
|---|
| 69 | pocket_hatena: true |
|---|
| 70 | --- expected: <a href="http://d.hatena.ne.jp/" rel="nofollow" class="url">http://d.hatena.ne.jp/</a><a href="http://mgw.hatena.ne.jp/?url=http%3A%2F%2Fd.hatena.ne.jp%2F;noimage=0;split=1" rel="nofollow" class="pocket_hatena">[ph]</a> |
|---|
| 71 | |
|---|
| 72 | === au_pcsv |
|---|
| 73 | --- input |
|---|
| 74 | text: http://d.hatena.ne.jp/ |
|---|
| 75 | conf: |
|---|
| 76 | au_pcsv: true |
|---|
| 77 | --- expected: <a href="http://d.hatena.ne.jp/" rel="nofollow" class="url">http://d.hatena.ne.jp/</a><a href="device:pcsiteviewer?url=http://d.hatena.ne.jp/" rel="nofollow" class="au_pcsv">[PCSV]</a> |
|---|
| 78 | |
|---|
| 79 | === google_gwt |
|---|
| 80 | --- input |
|---|
| 81 | text: http://d.hatena.ne.jp/ |
|---|
| 82 | conf: |
|---|
| 83 | google_gwt: true |
|---|
| 84 | --- expected: <a href="http://d.hatena.ne.jp/" rel="nofollow" class="url">http://d.hatena.ne.jp/</a><a href="http://www.google.co.jp/gwt/n?u=http%3A%2F%2Fd.hatena.ne.jp%2F;_gwt_noimg=0" rel="nofollow" class="google_gwt">[gwt]</a> |
|---|
| 85 | |
|---|