r1311@llin: dpavlin | 2007-08-23 22:16:00 +0200
[webpac2] / t / 5-output-json.t
diff --git a/t/5-output-json.t b/t/5-output-json.t
new file mode 100755 (executable)
index 0000000..e85b191
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/perl -w
+
+use Test::More tests => 7;
+use Test::Exception;
+use Cwd qw/abs_path/;
+use blib;
+use strict;
+
+BEGIN {
+use_ok( 'WebPAC::Output::JSON' );
+}
+
+ok(my $abs_path = abs_path($0), "abs_path");
+$abs_path =~ s#/[^/]*$#/#; #
+diag "abs_path: $abs_path";
+
+ok(my $out = new WebPAC::Output::JSON({
+       path => "$abs_path/out/test.js",
+}), "new");
+
+ok( $out->init, 'init' );
+
+my $ds = {
+       'Source' => {
+               'name' => 'Izvor: ',
+               'tag' => 'Source',
+               'display' => [ 'foo' ]
+               },
+       'ID' => {
+               'name' => 'ID',
+               'tag' => 'IDths',
+               'search' => [ 'bar' ],
+               'lookup_key' => [ 'bar' ]
+               },
+       'filename' => [ 'out/thes/001.html' ],
+       'name' => 'filename',
+       'tag' => 'filename'
+};
+
+throws_ok { $out->add( ) } qr/need id/, 'add without params';
+throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds';
+
+ok( $out->add( 42, $ds ), 'add' );
+
+