summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-03-04 08:45:52 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-03-04 08:45:52 +0100
commit04d800589cc2bbb2e6a61969547179a8b20c837e (patch)
tree794b087c1f1fb893b5b5d38b84cddb0a9141b08f
parent073b308012994c9c3173474a2180e5fa0b7597e3 (diff)
Some more App::Dthumb tests
-rwxr-xr-xlib/App/Dthumb.pm4
-rwxr-xr-xt/20-app-dthumb.t25
2 files changed, 26 insertions, 3 deletions
diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm
index 20dd983..b3aa1cf 100755
--- a/lib/App/Dthumb.pm
+++ b/lib/App/Dthumb.pm
@@ -119,8 +119,8 @@ sub new {
$conf{dir_data} //= '.dthumb';
# helpers to directly pass GetOptions results
- $conf{lightbox} //= !$conf{'no-lightbox'};
- $conf{names} //= !$conf{'no-names'};
+ $conf{lightbox} //= ( $conf{'no-lightbox'} ? 0 : 1 );
+ $conf{names} //= ( $conf{'no-names'} ? 0 : 1 );
$ref->{config} = \%conf;
diff --git a/t/20-app-dthumb.t b/t/20-app-dthumb.t
index 9a81d0b..b591866 100755
--- a/t/20-app-dthumb.t
+++ b/t/20-app-dthumb.t
@@ -4,10 +4,33 @@ use warnings;
use 5.010;
use autodie;
-use Test::More tests => 2;
+use Test::More tests => 13;
use_ok('App::Dthumb');
my $dthumb = App::Dthumb->new();
isa_ok($dthumb, 'App::Dthumb');
+
+isa_ok($dthumb->{data}, 'App::Dthumb::Data');
+
+is($dthumb->{config}->{lightbox}, 1, 'Lightbox enabled');
+is($dthumb->{config}->{names} , 1, 'Show image names');
+is($dthumb->{config}->{quality} , 75, 'Default quality');
+is($dthumb->{config}->{recreate}, 0, 'Do not recreate');
+is($dthumb->{config}->{size} , 200, 'Default size');
+is($dthumb->{config}->{spacing} , 1.1, 'Default spacing');
+is($dthumb->{config}->{title}, 'dthumb', 'title is cwd basename');
+
+$dthumb = App::Dthumb->new('no-lightbox' => 1);
+is($dthumb->{config}->{lightbox}, 0, 'Lightbox disabled');
+
+$dthumb = App::Dthumb->new('no-names' => 1);
+is($dthumb->{config}->{names}, 0, 'Image names disabled');
+
+$dthumb = App::Dthumb->new();
+
+@{$dthumb->{files}} = qw(a.png b.png c.png d.jpg);
+@{$dthumb->{old_thumbnails}} = 'e.png';
+
+is_deeply($dthumb->{files}, [$dthumb->get_files()], '$dthumb->get_files()');