File: node-suffix.t

package info (click to toggle)
libwiki-toolkit-formatter-usemod-perl 0.25-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 176 kB
  • sloc: perl: 258; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (5)
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
use strict;
use Test::More;
use Wiki::Toolkit::Formatter::UseMod;

eval { require Test::MockObject; };
if ( $@ ) {
    plan skip_all => "Can't find Test::MockObject";
}

plan tests => 2;

my $wikitext = <<WIKITEXT;

ExistingNode

NonExistentNode

WIKITEXT

my $wiki = Test::MockObject->new;
$wiki->mock( "node_exists",
             sub {
                 my ($self, $node) = @_;
                 return $node eq "ExistingNode" ? 1 : 0;
             } );

my $formatter = Wiki::Toolkit::Formatter::UseMod->new(
    node_prefix => "/wiki/",
    node_suffix => ".html",
    edit_prefix => "/wiki/edit/",
    edit_suffix => ".html",
);

my $html = $formatter->format( $wikitext, $wiki );

like( $html, qr|<a href="/wiki/ExistingNode.html">ExistingNode</a>|,
      "node_suffix works" );
like( $html, qr|<a href="/wiki/edit/NonExistentNode.html">|,
      "edit_suffix works" );