2 |
use strict; |
use strict; |
3 |
use warnings; |
use warnings; |
4 |
|
|
5 |
use Test::More tests => 2; |
use Test::More tests => 31; |
6 |
use lib 'lib'; |
use lib 'lib'; |
7 |
|
|
8 |
|
use Data::Dump qw/dump/; |
9 |
|
|
10 |
|
my $debug = @ARGV ? 0 : 1; |
11 |
|
|
12 |
BEGIN { |
BEGIN { |
13 |
|
use_ok('Frey::Bootstrap'); |
14 |
use_ok('Frey::Web'); |
use_ok('Frey::Web'); |
15 |
|
use_ok('Frey'); |
16 |
|
use_ok('Test::HTML::Lint'); |
17 |
|
} |
18 |
|
|
19 |
|
{ |
20 |
|
package Mock; |
21 |
|
use Moose; |
22 |
|
extends 'Frey'; |
23 |
|
with 'Frey::Web'; |
24 |
} |
} |
25 |
|
|
26 |
isa_ok( Frey::Web->meta, 'Moose::Meta::Role' ); |
isa_ok( Frey::Web->meta, 'Moose::Meta::Role' ); |
27 |
|
|
28 |
|
|
29 |
|
ok( my $o = Mock->new( debug => $debug, inline_smaller_than => 1 ), 'new' ); |
30 |
|
diag $o->dump(2) if $debug; |
31 |
|
|
32 |
|
ok( $o->add_head( '/static/lib/Joose.js' ), 'add_head js' ); |
33 |
|
|
34 |
|
ok( my @head = $o->head, 'js' ); |
35 |
|
|
36 |
|
diag dump( @head ) if $debug; |
37 |
|
|
38 |
|
ok( $o->add_head( '/static/introspect.css' ), 'add_head css' ); |
39 |
|
ok( $o->add_head( "<!--\nhead comment\n-->" ), 'add_head comment' ); |
40 |
|
ok( $o->add_head( "<span>head html</span>>" ), 'add_head html' ); |
41 |
|
|
42 |
|
html_ok( $o->warnings_html, 'warnings_html' ); |
43 |
|
|
44 |
|
ok( my $html = $o->page( title => 'Test', body => '<!-- in-body -->' ), 'page' ); |
45 |
|
diag $html if $debug; |
46 |
|
|
47 |
|
like( $html, qr{text/javascript.*\.js}, 'have js' ); |
48 |
|
like( $html, qr{text/css.*\.css}, 'have css' ); |
49 |
|
like( $html, qr{head comment}, 'have comment' ); |
50 |
|
like( $html, qr{head html}, 'have html' ); |
51 |
|
like( $html, qr{icon}, 'have icon' ); |
52 |
|
|
53 |
|
html_ok( $html, 'html lint' ); |
54 |
|
|
55 |
|
ok( my $s = $o->add_head( 'static/frey.css' ), 'add_head css' ); |
56 |
|
diag $s if $debug; |
57 |
|
ok( $s = $o->add_head( 'static/js/ext-2.1/ext-all.js' ), 'add_head js' ); |
58 |
|
diag $s if $debug; |
59 |
|
|
60 |
|
ok( $o->title, 'has title' ); |
61 |
|
|
62 |
|
ok( my $html2 = $o->page( title => 'Test2', body => '<!-- in-body 2 -->' ), 'page' ); |
63 |
|
diag $html2 if $debug; |
64 |
|
|
65 |
|
cmp_ok( length( $html ), '<', length( $html2 ), 'bigger html' ); |
66 |
|
|
67 |
|
like( $html2, qr{frey\.css}, 'have css' ); |
68 |
|
like( $html2, qr{ext}, 'have js' ); |
69 |
|
|
70 |
|
ok( my $error = $o->error('test,ignore'), 'error' ); |
71 |
|
diag $error if $debug; |
72 |
|
like( $error, qr{test,ignore.*$0}s, "have $0" ); |
73 |
|
|
74 |
|
ok( $o->dump_max_bytes, 'dump_max_bytes' ); |
75 |
|
|
76 |
|
ok( $html = $o->html_self, 'html_self' ); |
77 |
|
diag $html if $debug; |
78 |
|
like( $html, qr{=HASH}s, "have self" ); |
79 |
|
|
80 |
|
|