1 |
#!/usr/bin/perl -w |
2 |
|
3 |
use Test::More tests => 7; |
4 |
use Test::Exception; |
5 |
use Cwd qw/abs_path/; |
6 |
use blib; |
7 |
use strict; |
8 |
|
9 |
BEGIN { |
10 |
use_ok( 'WebPAC::Output::JSON' ); |
11 |
} |
12 |
|
13 |
ok(my $abs_path = abs_path($0), "abs_path"); |
14 |
$abs_path =~ s#/[^/]*$#/#; # |
15 |
diag "abs_path: $abs_path"; |
16 |
|
17 |
ok(my $out = new WebPAC::Output::JSON({ |
18 |
path => "$abs_path/out/test.js", |
19 |
}), "new"); |
20 |
|
21 |
ok( $out->init, 'init' ); |
22 |
|
23 |
my $ds = { |
24 |
'Source' => { |
25 |
'name' => 'Izvor: ', |
26 |
'tag' => 'Source', |
27 |
'display' => [ 'foo' ] |
28 |
}, |
29 |
'ID' => { |
30 |
'name' => 'ID', |
31 |
'tag' => 'IDths', |
32 |
'search' => [ 'bar' ], |
33 |
'lookup_key' => [ 'bar' ] |
34 |
}, |
35 |
'filename' => [ 'out/thes/001.html' ], |
36 |
'name' => 'filename', |
37 |
'tag' => 'filename' |
38 |
}; |
39 |
|
40 |
throws_ok { $out->add( ) } qr/need id/, 'add without params'; |
41 |
throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds'; |
42 |
|
43 |
ok( $out->add( 42, $ds ), 'add' ); |
44 |
|
45 |
|