aboutsummaryrefslogtreecommitdiff
path: root/t/bestlink.t
blob: ed748b0f28fb6b3b2d5051946ed06b0aa42eda39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 5;

sub test ($$$) {
	my $page=shift;
	my $link=shift;
	my @existing_pages=@{shift()};
	
	%IkiWiki::links=();
	foreach my $page (@existing_pages) {
		$IkiWiki::links{$page}=[];
	}

	return IkiWiki::bestlink($page, $link);
}

BEGIN { use_ok("IkiWiki"); }

is(test("bar", "foo", ["bar"]), "", "broken link");
is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link");
is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link");
is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");