Make doc navigation extensible
Change-Id: I6fffb2e33439d6c539d05bb65a3b81d4e2267f57
diff --git a/t/docembed.t b/t/docembed.t
new file mode 100644
index 0000000..24503f7
--- /dev/null
+++ b/t/docembed.t
@@ -0,0 +1,25 @@
+use Mojo::Base -strict;
+use Mojolicious::Lite;
+use Test::More;
+use Test::Mojo;
+use utf8;
+
+my $t = Test::Mojo->new('Kalamar' => {
+ Kalamar => {
+ api => 'xyz',
+ navi_ext => [
+ {
+ title => 'Privacy',
+ id => 'privacy'
+ }
+ ]
+ }
+});
+
+$t->get_ok('/doc')
+ ->text_is('nav > ul.nav > li.active a', 'KorAP')
+ ->text_is('nav > ul.nav > li:last-child a', 'Privacy')
+ ->element_exists('nav > ul.nav > li:last-child a[href=/doc/privacy#tutorial-top]')
+ ;
+
+done_testing;
diff --git a/t/docnavi.t b/t/docnavi.t
index e01c047..576db84 100644
--- a/t/docnavi.t
+++ b/t/docnavi.t
@@ -11,7 +11,8 @@
push(@{$app->plugins->namespaces}, 'Kalamar::Plugin');
# Establish test route
-$app->routes->get('/doc/*scope/:page')->to(cb => sub {})->name('doc');
+$app->routes->get('/doc/:page')->to(cb => sub {})->name('doc1');
+$app->routes->get('/doc/*scope/:page')->to(cb => sub {})->name('doc2');
# Load plugin to test
$app->plugin('KalamarHelpers');
@@ -261,6 +262,9 @@
'Path matches FAQ');
+is($app->doc_link_to('privacy', 'privacy'), '<a class="doc-link" href="/doc/privacy">privacy</a>');
+is($app->doc_link_to('privacy', 'korap', 'privacy'), '<a class="doc-link" href="/doc/korap/privacy">privacy</a>');
+
done_testing;
__END__