--- trunk/t/02-frey-web.t 2008/07/11 19:19:42 100 +++ trunk/t/02-frey-web.t 2008/11/26 07:57:12 532 @@ -2,12 +2,68 @@ use strict; use warnings; -use Test::More tests => 2; +use Test::More tests => 25; use lib 'lib'; +use Data::Dump qw/dump/; + +my $debug = @ARGV ? 0 : 1; + BEGIN { use_ok('Frey::Web'); + use_ok('Frey'); + use_ok('Test::HTML::Lint'); +} + +{ + package Mock; + use Moose; + extends 'Frey'; + with 'Frey::Web'; } isa_ok( Frey::Web->meta, 'Moose::Meta::Role' ); + +ok( my $o = Mock->new( debug => $debug, inline_smaller_than => 1 ), 'new' ); +diag $o->dump(2) if $debug; + +ok( $o->add_head( '/static/lib/Joose.js' ), 'add_head js' ); + +ok( my @head = $o->head, 'js' ); + +diag dump( @head ) if $debug; + +ok( $o->add_head( '/static/introspect.css' ), 'add_head css' ); +ok( $o->add_head( "" ), 'add_head html' ); + +ok( my $html = $o->page( title => 'Test', body => '' ), 'page' ); +diag $html if $debug; + +like( $html, qr{text/javascript.*\.js}, 'have js' ); +like( $html, qr{text/css.*\.css}, 'have css' ); +like( $html, qr{head html}, 'have html' ); +like( $html, qr{icon}, 'have icon' ); + +html_ok( $html, 'html lint' ); + +ok( my $s = $o->add_head( 'static/frey.css' ), 'add_head css' ); +diag $s if $debug; +ok( $s = $o->add_head( 'static/js/ext-2.1/ext-all.js' ), 'add_head js' ); +diag $s if $debug; + +ok( $o->title, 'has title' ); + +ok( my $html2 = $o->page( title => 'Test2', body => '' ), 'page' ); +diag $html2 if $debug; + +cmp_ok( length( $html ), '<', length( $html2 ), 'bigger html' ); + +like( $html2, qr{frey\.css}, 'have css' ); +like( $html2, qr{ext}, 'have js' ); + +ok( my $error = $o->error('test,ignore'), 'error' ); +diag $error if $debug; +like( $error, qr{test,ignore.*$0}s, "have $0" ); + +ok( $o->dump_max_bytes, 'dump_max_bytes' );