File: 01unit.t

package info (click to toggle)
libhtml-widgets-navmenu-perl 1.1000-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 636 kB
  • sloc: perl: 8,051; makefile: 9
file content (65 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl -w

use strict;

use Test::More tests => 9;

use HTML::Widgets::NavMenu ();

{
    my $text = "test/foo";

    my $url = HTML::Widgets::NavMenu::_text_to_url_obj($text);

    my $components = $url->_get_url();
    ok( scalar(@$components) == 2 );     # TEST
    ok( $components->[0] eq "test" );    # TEST
    ok( $components->[1] eq "foo" );     # TEST
    ok( !$url->_is_dir() );              # TEST

}

{
    my $url1 = HTML::Widgets::NavMenu::Url->new( ["links.html"], 0, "server" );
    my $url2 = HTML::Widgets::NavMenu::Url->new( ["links.html"], 0, "server" );
    my $rel_url = $url1->_get_relative_url( $url2, 0 );
    ok( $rel_url eq "./links.html", "Checking for same file to itself link" )
        ;                                # TEST
}

{
    my $root_url    = HTML::Widgets::NavMenu::Url->new( "",             1 );
    my $current_url = HTML::Widgets::NavMenu::Url->new( "open-source/", 1 );

    ok( $current_url->_get_relative_url( $root_url, 1 ) eq "../",
        "Checking for link to root directory" );    # TEST
}

{
    # TEST
    ok(
        (
            HTML::Widgets::NavMenu::_get_relative_url( "open-source/", "" ) eq
                "../"
        ),
        "_get_relative_url(): Checking for link to root directory"
    );
}

{
    eval { my $iter = HTML::Widgets::NavMenu::Iterator::Base->new(); };

    # TEST
    like( $@, qr{^nav_menu not specified}, "nav_menu not specified" );
}

{
    my $obj = HTML::Widgets::NavMenu::Object->new();

    # TEST
    isa_ok(
        $obj,
        "HTML::Widgets::NavMenu::Object",
        "Testing creation of object"
    );
}