Commits

Anonymous committed 5f19088

Nav-Menu:

Wrote a test to test the url_type behaviour of the leading_path component.
The test initially failed due to a bug in H::W::NavMenu, which has been
fixed in this commit.

  • Participants
  • Parent commits 1b599cc

Comments (0)

Files changed (2)

File module/lib/HTML/Widgets/NavMenu.pm

     my $callback = shift || (sub { });
     my $ptr = $self->{tree_contents};
     my $host = $ptr->{host};
-    my $rec_url_type = "rel";
+    my $rec_url_type = ($ptr->{rec_url_type} || "rel");
     my $idx = 0;
     my $internal_callback = sub {
         $callback->('idx' => $idx, 'ptr' => $ptr, 'host' => $host, 'rec_url_type' => $rec_url_type,);

File module/t/09leading-path.t

 
 use strict;
 
-use Test::More tests => 3;
+use Test::More tests => 13;
 
 use HTML::Widgets::NavMenu;
 
     is ($component->direct_url(), "../", "Testing for direct_url");
 }
 
+# This check tests the url_type behaviour of the leading-path
+{
+    my $nav_menu = HTML::Widgets::NavMenu->new(
+        'path_info' => "/yowza/howza/",
+        @{$test_data->{'rec_url_type_menu'}},
+    );
+
+    my $rendered = 
+        $nav_menu->render();
+
+    my @leading_path = @{$rendered->{'leading_path'}};
+
+    # TEST
+    ok ((scalar(@leading_path) == 3), "Checking for a leading path of len 3");
+
+    my $component = $leading_path[0];
+
+    # TEST
+    is ($component->title(), "T1 Title", "Testing for title of leading_path"); 
     
+    # TEST
+    is ($component->direct_url(), "http://www.hello.com/~shlomif/", 
+        "Testing for direct_url");
 
+    # TEST
+    is ($component->url_type(), "full_abs", "Testing for url_type");
+
+    $component = $leading_path[1];
+
+    # TEST
+    is ($component->label(), "Yowza", "Testing for label of leading_path"); 
+    
+    # TEST
+    is ($component->direct_url(), "../", 
+        "Testing for direct_url");
+
+    # TEST
+    is ($component->url_type(), "rel", "Testing for url_type");
+
+    $component = $leading_path[2];
+
+    # TEST
+    is ($component->label(), "This should be full_abs again", 
+        "Testing for label of leading_path"); 
+    
+    # TEST
+    is ($component->direct_url(), "http://www.hello.com/~shlomif/yowza/howza/", 
+        "Testing for direct_url");
+
+    # TEST
+    is ($component->url_type(), "full_abs", "Testing for url_type");
+}