Bug 19564: Add tests for _convert_sort_fields

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2017-12-22 15:21:51 -03:00
parent 8e07761f30
commit 3afd4a7e1a

View file

@ -17,7 +17,7 @@
use Modern::Perl;
use Test::More tests => 12;
use Test::More tests => 13;
use t::lib::Mocks;
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
@ -229,3 +229,26 @@ subtest 'build_query tests' => sub {
);
};
subtest "_convert_sort_fields" => sub {
plan tests => 1;
my @sort_by = $builder->_convert_sort_fields(qw( call_number_asc author_dsc ));
is_deeply(
\@sort_by,
[
{ field => 'callnum', direction => 'asc' },
{ field => 'author', direction => 'desc' }
],
'sort fields should have been split correctly'
);
# We could expect this to pass, but direction is undef instead of 'desc'
#@sort_by = $builder->_convert_sort_fields(qw( call_number_asc author_desc ));
#is_deeply(
# \@sort_by,
# [
# { field => 'callnum', direction => 'asc' },
# { field => 'author', direction => 'desc' }
# ],
# 'sort fields should have been split correctly'
#);
};