first cut into WebPAC::DB
[webpac2] / t / 5-output-tt.t
diff --git a/t/5-output-tt.t b/t/5-output-tt.t
new file mode 100755 (executable)
index 0000000..318c6b5
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/perl -w
+
+use Test::More tests => 5;
+use Test::Exception;
+use Cwd qw/abs_path/;
+use blib;
+use strict;
+
+BEGIN {
+use_ok( 'WebPAC::Output::TT' );
+}
+
+ok(my $abs_path = abs_path($0), "abs_path");
+$abs_path =~ s#/[^/]*$#/#;
+diag "abs_path: $abs_path";
+
+ok(my $tt = new WebPAC::Output::TT(
+       include_path => "$abs_path../conf/output/tt",
+       debug => 1 ),
+"new");
+
+my @ds = [ {
+       'name' => 'Izvor: ',
+       'tag' => 'Source',
+       'display' => [ 'foo' ]
+       }, {
+       'name' => 'ID',
+       'tag' => 'IDths',
+       'swish' => [ 'bar' ],
+       'lookup_key' => [ 'bar' ]
+       }, {
+       'filename' => [ 'out/thes/001.html' ],
+       'name' => 'filename',
+       'tag' => 'filename'
+       },
+];
+
+throws_ok { $tt->apply( template => 'foo', data => [] ) } qr/error.*foo/, "apply without template";
+
+cmp_ok(my $text = $tt->apply( template => 'text.tt', data => @ds ), '=~', qr/Source.*foo/, "apply");
+
+diag $text;
+