2 |
use strict; |
use strict; |
3 |
use warnings; |
use warnings; |
4 |
|
|
5 |
use Test::More tests => 18; |
use Test::More tests => 25; |
6 |
use lib 'lib'; |
use lib 'lib'; |
7 |
|
|
8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
25 |
isa_ok( Frey::Web->meta, 'Moose::Meta::Role' ); |
isa_ok( Frey::Web->meta, 'Moose::Meta::Role' ); |
26 |
|
|
27 |
|
|
28 |
ok( my $o = Mock->new( debug => $debug ), 'new' ); |
ok( my $o = Mock->new( debug => $debug, inline_smaller_than => 1 ), 'new' ); |
29 |
diag $o->dump(2) if $debug; |
diag $o->dump(2) if $debug; |
30 |
|
|
31 |
ok( $o->add_js( '/static/lib/Joose.js' ), 'add_js' ); |
ok( $o->add_head( '/static/lib/Joose.js' ), 'add_head js' ); |
32 |
|
|
33 |
ok( my @js = $o->js, 'js' ); |
ok( my @head = $o->head, 'js' ); |
34 |
|
|
35 |
diag dump( @js ) if $debug; |
diag dump( @head ) if $debug; |
36 |
|
|
37 |
ok( $o->add_css( '/static/introspect.css' ), 'add_css' ); |
ok( $o->add_head( '/static/introspect.css' ), 'add_head css' ); |
38 |
|
ok( $o->add_head( "<!--\nhead html\n-->" ), 'add_head html' ); |
39 |
|
|
40 |
ok( my $html = $o->page( title => 'Test', body => '<!-- in-body -->' ), 'page' ); |
ok( my $html = $o->page( title => 'Test', body => '<!-- in-body -->' ), 'page' ); |
41 |
diag $html if $debug; |
diag $html if $debug; |
42 |
|
|
43 |
like( $html, qr{text/javascript.*\.js}, 'have js' ); |
like( $html, qr{text/javascript.*\.js}, 'have js' ); |
44 |
like( $html, qr{text/css.*\.css}, 'have css' ); |
like( $html, qr{text/css.*\.css}, 'have css' ); |
45 |
|
like( $html, qr{head html}, 'have html' ); |
46 |
|
like( $html, qr{icon}, 'have icon' ); |
47 |
|
|
48 |
html_ok( $html, 'html lint' ); |
html_ok( $html, 'html lint' ); |
49 |
|
|
50 |
ok( my $s = $o->add_head( 'static/app.css' ), 'add_head css' ); |
ok( my $s = $o->add_head( 'static/frey.css' ), 'add_head css' ); |
51 |
diag $s if $debug; |
diag $s if $debug; |
52 |
ok( $s = $o->add_head( 'static/js/ext-2.1/ext-all.js' ), 'add_head js' ); |
ok( $s = $o->add_head( 'static/js/ext-2.1/ext-all.js' ), 'add_head js' ); |
53 |
diag $s if $debug; |
diag $s if $debug; |
54 |
|
|
55 |
|
ok( $o->title, 'has title' ); |
56 |
|
|
57 |
ok( my $html2 = $o->page( title => 'Test2', body => '<!-- in-body 2 -->' ), 'page' ); |
ok( my $html2 = $o->page( title => 'Test2', body => '<!-- in-body 2 -->' ), 'page' ); |
58 |
diag $html2 if $debug; |
diag $html2 if $debug; |
59 |
|
|
60 |
cmp_ok( length( $html ), '<', length( $html2 ), 'bigger html' ); |
cmp_ok( length( $html ), '<', length( $html2 ), 'bigger html' ); |
61 |
|
|
62 |
like( $html2, qr{app\.css}, 'have css' ); |
like( $html2, qr{frey\.css}, 'have css' ); |
63 |
like( $html2, qr{ext}, 'have js' ); |
like( $html2, qr{ext}, 'have js' ); |
64 |
|
|
65 |
|
ok( my $error = $o->error('test,ignore'), 'error' ); |
66 |
|
diag $error if $debug; |
67 |
|
like( $error, qr{test,ignore.*$0}s, "have $0" ); |
68 |
|
|
69 |
|
ok( $o->dump_max_bytes, 'dump_max_bytes' ); |