File: 17nav-coords-unit.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 (120 lines) | stat: -rw-r--r-- 2,770 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/perl

use strict;
use warnings;

use lib './t/lib';

use Test::More tests => 15;

use HTML::Widgets::NavMenu ();

use HTML::Widgets::NavMenu::Test::Data;

my $test_data = get_test_data();

{
    my $nav_menu = HTML::Widgets::NavMenu->new(
        'path_info' => "/resume.html",
        @{ $test_data->{'with_skips'} },
    );

    # TEST
    is_deeply(
        $nav_menu->_get_current_coords(),
        [ 1, 2 ],
        "_get_current_coords()"
    );

    # TEST
    is_deeply( $nav_menu->_get_next_coords(),
        [2], "Testing that _get_next_coords does _not_ skip skips by default" );

    # TEST
    is_deeply(
        $nav_menu->_get_prev_coords(),
        [ 1, 1 ],
        "Testing _get_prev_coords"
    );

    # TEST
    is_deeply( $nav_menu->_get_up_coords(), [1], "Testing _get_up_coords()" );

    # TEST
    is_deeply( $nav_menu->_get_up_coords( [ 1, 2 ] ),
        [1], "Testing _get_up_coords()" );

    # TEST
    is_deeply( $nav_menu->_get_top_coords(), [0], "Testing _get_top_coords()" );

    # TEST
    is_deeply( $nav_menu->_get_top_coords( [ 1, 2 ] ),
        [0], "Testing _get_top_coords()" );

    # TEST
    is_deeply(
        $nav_menu->_get_coords_while_skipping_skips(
            \&HTML::Widgets::NavMenu::_get_next_coords
        ),
        [3],
        "Testing that skipping(_get_next_coords) does skip skips by default"
    );

    # TEST
    is_deeply(
        $nav_menu->_get_coords_while_skipping_skips(
            \&HTML::Widgets::NavMenu::_get_prev_coords
        ),
        [ 1, 1 ],
        "Testing skipping(_get_prev_coords)"
    );

    # TEST
    is_deeply(
        $nav_menu->_get_coords_while_skipping_skips(
            \&HTML::Widgets::NavMenu::_get_next_coords,
            [ 1, 2 ]
        ),
        [3],
        "Testing that skipping(_get_next_coords) with explicit coords"
    );

}

{
    my $nav_menu = HTML::Widgets::NavMenu->new(
        'path_info' => "/open-source/",
        @{ $test_data->{'with_skips'} },
    );

    # TEST
    is_deeply( $nav_menu->_get_current_coords(), [3], "_get_current_coords()" );

    # TEST
    is_deeply(
        $nav_menu->_get_next_coords(),
        [ 3, 0 ],
        "Testing _get_next_coords"
    );

    # TEST
    is_deeply( $nav_menu->_get_prev_coords(), [2], "Testing _get_prev_coords" );

    # TEST
    is_deeply(
        $nav_menu->_get_coords_while_skipping_skips(
            \&HTML::Widgets::NavMenu::_get_next_coords
        ),
        [ 3, 1 ],
        "Testing that skipping(_get_next_coords) does skip skips by default"
    );

    # TEST
    is_deeply(
        $nav_menu->_get_coords_while_skipping_skips(
            \&HTML::Widgets::NavMenu::_get_prev_coords
        ),
        [ 1, 2 ],
        "Testing skipping(_get_prev_coords)"
    );
}