2 |
use strict; |
use strict; |
3 |
use warnings; |
use warnings; |
4 |
|
|
5 |
use Test::More tests => 2; |
use Test::More tests => 21; |
6 |
use lib 'lib'; |
use lib 'lib'; |
7 |
|
|
8 |
|
use Data::Dump qw/dump/; |
9 |
|
|
10 |
|
my $debug = 1 if @ARGV; |
11 |
|
|
12 |
BEGIN { |
BEGIN { |
13 |
use_ok('Frey::Web'); |
use_ok('Frey::Web'); |
14 |
|
use_ok('Frey'); |
15 |
|
use_ok('Test::HTML::Lint'); |
16 |
|
} |
17 |
|
|
18 |
|
{ |
19 |
|
package Mock; |
20 |
|
use Moose; |
21 |
|
extends 'Frey'; |
22 |
|
with 'Frey::Web'; |
23 |
} |
} |
24 |
|
|
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, inline_smaller_than => 1 ), 'new' ); |
29 |
|
diag $o->dump(2) if $debug; |
30 |
|
|
31 |
|
ok( $o->add_head( '/static/lib/Joose.js' ), 'add_head js' ); |
32 |
|
|
33 |
|
ok( my @head = $o->head, 'js' ); |
34 |
|
|
35 |
|
diag dump( @head ) if $debug; |
36 |
|
|
37 |
|
ok( $o->add_head( '/static/introspect.css' ), 'add_head css' ); |
38 |
|
ok( $o->add_head( '<!-- head html -->' ), 'add_head html' ); |
39 |
|
|
40 |
|
ok( my $html = $o->page( title => 'Test', body => '<!-- in-body -->' ), 'page' ); |
41 |
|
diag $html if $debug; |
42 |
|
|
43 |
|
like( $html, qr{text/javascript.*\.js}, 'have js' ); |
44 |
|
like( $html, qr{text/css.*\.css}, 'have css' ); |
45 |
|
like( $html, qr{head html}, 'have html' ); |
46 |
|
|
47 |
|
html_ok( $html, 'html lint' ); |
48 |
|
|
49 |
|
ok( my $s = $o->add_head( 'static/frey.css' ), 'add_head css' ); |
50 |
|
diag $s if $debug; |
51 |
|
ok( $s = $o->add_head( 'static/js/ext-2.1/ext-all.js' ), 'add_head js' ); |
52 |
|
diag $s if $debug; |
53 |
|
|
54 |
|
ok( $o->title, 'has title' ); |
55 |
|
|
56 |
|
ok( my $html2 = $o->page( title => 'Test2', body => '<!-- in-body 2 -->' ), 'page' ); |
57 |
|
diag $html2 if $debug; |
58 |
|
|
59 |
|
cmp_ok( length( $html ), '<', length( $html2 ), 'bigger html' ); |
60 |
|
|
61 |
|
like( $html2, qr{frey\.css}, 'have css' ); |
62 |
|
like( $html2, qr{ext}, 'have js' ); |