Bug 32721: Add unit tests

Unit tests to test two new functions: GetBranchSpecificJS and GetBranchSpecificCSS

Test plan:
1) In the shell run prove -t t/db_dependent/Template/Plugin/Branches.t

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Matt Blenkinsop 2023-01-27 12:59:10 +00:00 committed by Tomas Cohen Arazi
parent 6eea26c729
commit dd3d59f1f8
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 28 additions and 1 deletions

View File

@ -16,7 +16,7 @@
use Modern::Perl;
use Test::More tests => 3;
use Test::More tests => 4;
use Test::MockModule;
use C4::Context;
@ -217,3 +217,30 @@ subtest 'pickup_locations() tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'branch specfic js and css' => sub {
plan tests => 2;
$schema->storage->txn_begin;
my $newbranch = $builder->build({
source => 'Branch',
value => {
branchcode => 'AAA',
branchname => 'Specific Branch',
userjs => 'console.log(\'Hello World\');',
usercss => 'body { background-color: blue; }'
}
});
my $plugin = Koha::Template::Plugin::Branches->new();
my $userjs = $plugin->GetBranchSpecificJS($newbranch->{branchcode});
is($userjs, $newbranch->{userjs},'received correct JS string from function');
my $usercss = $plugin->GetBranchSpecificCSS($newbranch->{branchcode});
is($usercss, $newbranch->{usercss},'received correct CSS string from function');
$schema->storage->txn_rollback;
};