From b0b421b1c682d8f162e1b89603ecbb4696a199a1 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 5 Aug 2020 11:55:28 -0300 Subject: [PATCH] Bug 26143: The API is always paginated Signed-off-by: Tomas Cohen Arazi --- t/Koha/REST/Plugin/Pagination.t | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/t/Koha/REST/Plugin/Pagination.t b/t/Koha/REST/Plugin/Pagination.t index 43e9f072f2..adf3001c4f 100644 --- a/t/Koha/REST/Plugin/Pagination.t +++ b/t/Koha/REST/Plugin/Pagination.t @@ -66,7 +66,7 @@ get '/pagination_headers_without_page_size' => sub { get '/pagination_headers_without_page' => sub { my $c = shift; - $c->add_pagination_headers({ total => 10, params => { _per_page => 4, firstname => 'Jonathan' } }); + $c->add_pagination_headers({ total => 10, params => { _per_page => 3, firstname => 'Jonathan' } }); $c->render( json => { ok => 1 }, status => 200 ); }; @@ -79,7 +79,7 @@ use t::lib::Mocks; subtest 'add_pagination_headers() tests' => sub { - plan tests => 64; + plan tests => 75; my $t = Test::Mojo->new; @@ -151,10 +151,19 @@ subtest 'add_pagination_headers() tests' => sub { $t->get_ok('/pagination_headers_without_page') ->status_is( 200 ) - ->header_is( 'X-Total-Count' => undef, 'X-Total-Count header absent' ) - ->header_is( 'Link' => undef, 'Link header absent' ); - - + ->header_is( 'X-Total-Count' => 10, 'X-Total-Count header present, even without page param' ) + ->header_unlike( 'Link' => qr/; rel="prev",/, 'First page, no previous' ) + ->header_unlike( 'Link' => qr/; rel="prev",/, 'First page, no previous' ) + ->header_unlike( 'Link' => qr/; rel="prev",/, 'First page, no previous' ) + ->header_like( 'Link' => qr/; rel="next",/ ) + ->header_like( 'Link' => qr/; rel="next",/ ) + ->header_like( 'Link' => qr/; rel="next",/ ) + ->header_like( 'Link' => qr/; rel="first",/ ) + ->header_like( 'Link' => qr/; rel="first",/ ) + ->header_like( 'Link' => qr/; rel="first",/ ) + ->header_like( 'Link' => qr/; rel="last"/ ) + ->header_like( 'Link' => qr/; rel="last"/ ) + ->header_like( 'Link' => qr/; rel="last"/ ); }; subtest 'dbic_merge_pagination() tests' => sub { -- 2.28.0