File: formatter_idlink.t

package info (click to toggle)
libmojomojo-perl 1.11%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,496 kB
  • ctags: 927
  • sloc: perl: 14,671; sh: 148; xml: 120; makefile: 8; ruby: 6
file content (64 lines) | stat: -rw-r--r-- 1,494 bytes parent folder | download | duplicates (4)
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
61
62
63
64
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 7;
use lib 't/lib';
use FakeCatalystObject;

BEGIN {
    use_ok 'MojoMojo::Formatter::IDLink';
    use_ok 'Catalyst::Test', 'MojoMojo';
}

my $fake_c;
( undef, $fake_c ) = ctx_request('/');

{
    my $content = 'ask {{id bayashi}}';
    MojoMojo::Formatter::IDLink->format_content(\$content, $fake_c);
    is(
        $content,
        qq|ask <a href="http://twitter.com/bayashi">bayashi</a>\n|,
        'default',
    );
}

{
    my $content = 'ask {{id:htb bayashi_net}}';
    MojoMojo::Formatter::IDLink->format_content(\$content, $fake_c);
    is(
        $content,
        qq|ask <a href="http://b.hatena.ne.jp/bayashi_net">bayashi_net</a>\n|,
        'htb',
    );
}

{
    my $content = 'ask {{id:htd bayashi_net}}';
    MojoMojo::Formatter::IDLink->format_content(\$content, $fake_c);
    is(
        $content,
        qq|ask <a href="http://d.hatena.ne.jp/bayashi_net">bayashi_net</a>\n|,
        'htd',
    );
}

{
    my $content = 'ask {{id:cpan bayashi}}';
    MojoMojo::Formatter::IDLink->format_content(\$content, $fake_c);
    is(
        $content,
        qq|ask <a href="http://search.cpan.org/~bayashi/">bayashi</a>\n|,
        'cpan',
    );
}

{
    my $content = 'ask {{id:fb dai.okabayashi}}';
    MojoMojo::Formatter::IDLink->format_content(\$content, $fake_c);
    is(
        $content,
        qq|ask <a href="http://facebook.com/dai.okabayashi">dai.okabayashi</a>\n|,
        'facebook',
    );
}