summaryrefslogtreecommitdiff
path: root/t/Helper.t
diff options
context:
space:
mode:
Diffstat (limited to 't/Helper.t')
-rw-r--r--t/Helper.t64
1 files changed, 32 insertions, 32 deletions
diff --git a/t/Helper.t b/t/Helper.t
index 99758a3..45d0e4f 100644
--- a/t/Helper.t
+++ b/t/Helper.t
@@ -85,73 +85,73 @@ subtest 'pagination' => sub {
%res = JWebmail::Plugin::Helper::_paginate(first_item => 0, page_size => 10, total_items => 55);
- is $res{first_item}, 1;
- is $res{last_item}, 10;
+ is $res{first_item}, 0;
+ is $res{last_item}, 9;
is $res{total_items}, 55;
is $res{page_size}, 10;
is $res{total_pages}, 6;
- is $res{current_page}, 1;
+ is $res{current_page}, 0;
- is_deeply $res{first_page}, [1, 10], 'first';
- is_deeply $res{prev_page}, [1, 10], 'prev';
- is_deeply $res{next_page}, [11, 20], 'next';
- is_deeply $res{last_page}, [51, 55], 'last';
+ is_deeply $res{first_page}, [0, 10], 'first';
+ is_deeply $res{prev_page}, [0, 10], 'prev';
+ is_deeply $res{next_page}, [10, 20], 'next';
+ is_deeply $res{last_page}, [50, 55], 'last';
%res = JWebmail::Plugin::Helper::_paginate(first_item => 10, page_size => 10, total_items => 55);
- is $res{first_item}, 11;
- is $res{last_item}, 20;
+ is $res{first_item}, 10;
+ is $res{last_item}, 19;
is $res{total_items}, 55;
is $res{page_size}, 10;
is $res{total_pages}, 6;
- is $res{current_page}, 2;
+ is $res{current_page}, 1;
- is_deeply $res{first_page}, [1, 10], 'first';
- is_deeply $res{prev_page}, [1, 10], 'prev';
- is_deeply $res{next_page}, [21, 30], 'next';
- is_deeply $res{last_page}, [51, 55], 'last';
+ is_deeply $res{first_page}, [0, 10], 'first';
+ is_deeply $res{prev_page}, [0, 10], 'prev';
+ is_deeply $res{next_page}, [20, 30], 'next';
+ is_deeply $res{last_page}, [50, 55], 'last';
%res = JWebmail::Plugin::Helper::_paginate(first_item => 20, page_size => 10, total_items => 55);
- is $res{first_item}, 21;
- is $res{last_item}, 30;
+ is $res{first_item}, 20;
+ is $res{last_item}, 29;
is $res{total_items}, 55;
is $res{page_size}, 10;
is $res{total_pages}, 6;
- is $res{current_page}, 3;
+ is $res{current_page}, 2;
- is_deeply $res{first_page}, [1, 10], 'first';
- is_deeply $res{prev_page}, [11, 20], 'prev';
- is_deeply $res{next_page}, [31, 40], 'next';
- is_deeply $res{last_page}, [51, 55], 'last';
+ is_deeply $res{first_page}, [0, 10], 'first';
+ is_deeply $res{prev_page}, [10, 20], 'prev';
+ is_deeply $res{next_page}, [30, 40], 'next';
+ is_deeply $res{last_page}, [50, 55], 'last';
%res = JWebmail::Plugin::Helper::_paginate(first_item => 50, page_size => 10, total_items => 55);
- is $res{first_item}, 51;
- is $res{last_item}, 55;
+ is $res{first_item}, 50;
+ is $res{last_item}, 54;
is $res{total_items}, 55;
is $res{page_size}, 10;
is $res{total_pages}, 6;
- is $res{current_page}, 6;
+ is $res{current_page}, 5;
- is_deeply $res{first_page}, [1, 10], 'first';
- is_deeply $res{prev_page}, [41, 50], 'prev';
- is_deeply $res{next_page}, [51, 55], 'next';
- is_deeply $res{last_page}, [51, 55], 'last';
+ is_deeply $res{first_page}, [0, 10], 'first';
+ is_deeply $res{prev_page}, [40, 50], 'prev';
+ is_deeply $res{next_page}, [50, 55], 'next';
+ is_deeply $res{last_page}, [50, 55], 'last';
%res = JWebmail::Plugin::Helper::_paginate(first_item => 0, page_size => 10, total_items => 0);
- is $res{first_item}, 0;
- is $res{last_item}, 0;
+ ok !defined $res{first_item};
+ ok !defined $res{last_item};
is $res{total_items}, 0;
is $res{page_size}, 10;
is $res{total_pages}, 0;
- is $res{current_page}, 1;
+ is $res{current_page}, 0;
is_deeply $res{first_page}, [0, 0], 'first';
is_deeply $res{prev_page}, [0, 0], 'prev';
@@ -181,4 +181,4 @@ subtest 'pagination' => sub {
};
-done_testing; \ No newline at end of file
+done_testing;