1. Shlomi Fish
  2. perl-HTML-Widgets-NavMenu

Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed c9d200d

Nav-Menu:

Added tests to test the role header.

  • Participants
  • Parent commits 5e8ad38
  • Branches default
  • Tags before-switching-nav-menu-render-to-iter-with-extra-tests

Comments (0)

Files changed (2)

File HTML/Widgets/NavMenu/Test/Data.pm

View file
     },
 );
 
+my @header_role_nav_menu =
+(
+    'current_host' => "default",
+    'hosts' => { 'default' => { 'base_url' => "http://www.hello.com/" }, },
+    'tree_contents' =>
+    {
+        'host' => "default",
+        'value' => "Top 1",
+        'title' => "T1 Title",
+        'expand_re' => "",
+        'subs' =>
+        [
+            {
+                'value' => "Home",
+                'url' => "",
+            },
+            {
+                'value' => "About Me",
+                'title' => "About Myself",
+                'url' => "me/",
+                'role' => "header",
+                'show_always' => 1,
+                'subs' =>
+                [
+                    {
+                        'value' => "Sub Me",
+                        'url' => "me/sub-me1/",
+                    },
+                    {
+                        'value' => "Sub Me 2",
+                        'url' => "me/sub-me-two/",
+                    },
+                ],
+            },
+        ],
+    },
+);
+
 
 sub get_test_data
 {
             'items_in_sub' => \@items_in_sub_nav_menu,
             'separator' => \@separator_nav_menu,
             'hidden_item' => \@hidden_item_nav_menu,
+            'header_role' => \@header_role_nav_menu,
         };
 }
 

File t/04nav-menu.t

View file
 
 use strict;
 
-use Test::More tests => 8;
+use Test::More tests => 10;
 
 use Shlomif::NavMenu;
 
         "Nav Menu with Hidden Item"); 
 }
 
+
+{
+    my $nav_menu = Shlomif::NavMenu->new(
+        'path_info' => "/good/",
+        @{$test_data->{'header_role'}},
+    );
+
+    my $rendered = 
+        $nav_menu->render(
+            'no_ie' => "true",
+            'styles' =>
+            {
+                'bar' => 'nav',
+                'level0' => 'navbarmain',
+                'level1' => 'navbarnested',
+                'level2' => "navbarnested",
+                'level3' => "navbarnested",
+                'level4' => "navbarnested",
+                'list' => "navbarmain",
+            },
+        );
+
+    my $expected_string = <<"EOF";
+<ul class="navbarmain">
+<li>
+<a href="../">Home</a>
+</li>
+</ul>
+<h2>
+<a href="../me/" title="About Myself">About Me</a>
+</h2>
+<ul class="navbarmain">
+<li>
+<a href="../me/sub-me1/">Sub Me</a>
+</li>
+<li>
+<a href="../me/sub-me-two/">Sub Me 2</a>
+</li>
+</ul>
+EOF
+
+    # TEST
+    ok (validate_nav_menu($rendered, $expected_string), 
+        "Nav Menu with a role of \"header\""); 
+}
+
+{
+    my $nav_menu = Shlomif::NavMenu->new(
+        'path_info' => "/me/",
+        @{$test_data->{'header_role'}},
+    );
+
+    my $rendered = 
+        $nav_menu->render(
+            'no_ie' => "true",
+            'styles' =>
+            {
+                'bar' => 'nav',
+                'level0' => 'navbarmain',
+                'level1' => 'navbarnested',
+                'level2' => "navbarnested",
+                'level3' => "navbarnested",
+                'level4' => "navbarnested",
+                'list' => "navbarmain",
+            },
+        );
+
+    my $expected_string = <<"EOF";
+<ul class="navbarmain">
+<li>
+<a href="../">Home</a>
+</li>
+</ul>
+<h2>
+<b>About Me</b>
+</h2>
+<ul class="navbarmain">
+<li>
+<a href="sub-me1/">Sub Me</a>
+</li>
+<li>
+<a href="sub-me-two/">Sub Me 2</a>
+</li>
+</ul>
+EOF
+
+    # TEST
+    ok (validate_nav_menu($rendered, $expected_string), 
+        "Nav Menu with a selected item with a role of \"header\" "); 
+}
+