1 |
#!/usr/bin/perl |
2 |
use strict; |
3 |
use warnings; |
4 |
|
5 |
my $debug = @ARGV ? 1 : 0; |
6 |
|
7 |
use Test::More tests => 7; |
8 |
use lib 'lib'; |
9 |
|
10 |
use Data::Dump qw/dump/; |
11 |
|
12 |
BEGIN { |
13 |
use_ok('Frey::jQuery::flot'); |
14 |
} |
15 |
|
16 |
my $param = { |
17 |
request_url => '/', |
18 |
debug => $debug, |
19 |
}; |
20 |
|
21 |
ok( my $o = Frey::jQuery::flot->new( %$param, |
22 |
sponge => { |
23 |
rows => [ [ '2009-01-05' ] ], |
24 |
NAME => [ 'foo' ], |
25 |
}, |
26 |
), 'new' ); |
27 |
ok( my $markup = $o->as_markup, 'as_markup' ); |
28 |
diag $markup if $debug; |
29 |
like( $markup, qr/\.plot/, 'markup content' ); |
30 |
|
31 |
ok( my $invalid = Frey::jQuery::flot->new( %$param, |
32 |
sponge => { |
33 |
rows => [ [ 0 ] ], |
34 |
NAME => [ 'invalid' ], |
35 |
}, |
36 |
), 'new with invalid time' ); |
37 |
eval { $invalid->as_markup }; |
38 |
ok( $@, 'died' ); |
39 |
like( $@, qr/time/, 'invalid time' ); |
40 |
|