Bug 19370: Unit tests
Signed-off-by: Lari Taskula <lari.taskula@jns.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
4b07ae3f41
commit
2485afc57c
|
|
@ -67,9 +67,21 @@ get '/query_full' => sub {
|
|||
);
|
||||
};
|
||||
|
||||
get '/dbic_merge_sorting' => sub {
|
||||
my $c = shift;
|
||||
my $attributes = { a => 'a', b => 'b' };
|
||||
$attributes = $c->dbic_merge_sorting(
|
||||
{
|
||||
attributes => $attributes,
|
||||
params => { _match => 'exact', _order_by => 'uno|-dos|+tres' }
|
||||
}
|
||||
);
|
||||
$c->render( json => $attributes, status => 200 );
|
||||
};
|
||||
|
||||
# The tests
|
||||
|
||||
use Test::More tests => 1;
|
||||
use Test::More tests => 2;
|
||||
use Test::Mojo;
|
||||
|
||||
subtest 'extract_reserved_params() tests' => sub {
|
||||
|
|
@ -98,3 +110,16 @@ subtest 'extract_reserved_params() tests' => sub {
|
|||
} );
|
||||
|
||||
};
|
||||
|
||||
subtest 'dbic_merge_sorting() tests' => sub {
|
||||
|
||||
plan tests => 5;
|
||||
|
||||
my $t = Test::Mojo->new;
|
||||
|
||||
$t->get_ok('/dbic_merge_sorting')
|
||||
->status_is(200)
|
||||
->json_is( '/a' => 'a', 'Existing values are kept (a)' )
|
||||
->json_is( '/b' => 'b', 'Existing values are kept (b)' )
|
||||
->json_is( '/order_by' => [ 'uno', { -desc => 'dos' }, { -asc => 'tres' } ] );
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue