From 1411d79c0f307d55a25565a9149d64eb5f6129b6 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Fri, 27 Jan 2023 12:59:10 +0000 Subject: [PATCH] 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 --- t/db_dependent/Template/Plugin/Branches.t | 29 ++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Template/Plugin/Branches.t b/t/db_dependent/Template/Plugin/Branches.t index a1145d6693e..fe23f008750 100755 --- a/t/db_dependent/Template/Plugin/Branches.t +++ b/t/db_dependent/Template/Plugin/Branches.t @@ -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; +}; -- 2.30.2