1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 6;
use lib 't/lib';
use FakeCatalystObject;
BEGIN {
$ENV{CATALYST_CONFIG} = 't/var/mojomojo.yml';
use_ok 'MojoMojo::Formatter::WikipediaLink';
use_ok 'Catalyst::Test', 'MojoMojo';
}
my $fake_c;
( undef, $fake_c ) = ctx_request('/');
my $lang = $fake_c->pref('default_lang');
#----- ASCII
{
my $content = 'see {{wikipedia Perl}}';
MojoMojo::Formatter::WikipediaLink->format_content(\$content, $fake_c);
is(
$content,
qq|see <a href="http://$lang.wikipedia.org/wiki/Perl">Perl</a>\n|,
'default link',
);
}
{
my $content = 'see {{wikipedia:ja Perl}}';
MojoMojo::Formatter::WikipediaLink->format_content(\$content, $fake_c);
is(
$content,
qq|see <a href="http://ja.wikipedia.org/wiki/Perl">Perl</a>\n|,
'specified language',
);
}
{
my $content = 'see {{wikipedia:ja こんにちは}}';
MojoMojo::Formatter::WikipediaLink->format_content(\$content, $fake_c);
is(
$content,
qq|see <a href="http://ja.wikipedia.org/wiki/%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF">こんにちは</a>\n|,
'unicode keyword',
);
}
{
my $content = 'see {{wikipedia Larry Wall}}';
MojoMojo::Formatter::WikipediaLink->format_content(\$content, $fake_c);
is(
$content,
qq|see <a href="http://$lang.wikipedia.org/wiki/Larry%20Wall">Larry Wall</a>\n|,
'Larry Wall ;-P',
);
}
|