Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test all of the wrapper functionlaity.
  • Loading branch information
theory committed Nov 9, 2009
1 parent 97415e6 commit b171bfb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -16,6 +16,7 @@ requires 'Exception::Class::DBI' => '1.00';
requires 'parent';
requires 'Config::General'; # This should reflect the config file format you've chosen
requires 'Test::MockObject';
requires 'Test::XPath';
# See Catalyst::Plugin::ConfigLoader for supported formats
catalyst;

Expand Down
35 changes: 33 additions & 2 deletions t/view_HTML.t
Expand Up @@ -28,7 +28,7 @@ ok my $output = $view->render($c, 'books/list', {
title => 'Book List',
books => $sth,
}), 'Render the "books/list" template';
#diag $output;
diag $output;

# Test output using Test::XPath.
my $tx = Test::XPath->new( xml => $output, is_html => 1);
Expand All @@ -37,7 +37,7 @@ test_basics($tx, 'Book List');
# Call this function for every request to make sure that they all
# have the same basic structure.
sub test_basics {
my ($tx, $title) = @_;
my ($tx, $title, $msg, $err) = @_;

# Some basic sanity-checking.
$tx->is( 'count(/html)', 1, 'Should have 1 html element' );
Expand All @@ -55,4 +55,35 @@ sub test_basics {
'/static/css/main.css',
'Should load the CSS',
);

$tx->ok('/html/body/div[@id="header"]', sub {
$_->ok('./img[@src="/static/images/btn_88x31_powered.png"]');
$_->is('./h1', $title);
}, 'Should have header');

$tx->ok('/html/body/div[@id="bodyblock"]', sub {
$_->ok('./div[@id="menu"]', sub {
$_->is('./h3', 'Navigation', 'header should be "Navigation"');
$_->ok('./ul', => sub {
$_->ok('./li[1]', sub {
$_->is(
'./a[@href="/books/list"]',
'Home',
'Should have Home'
);
}, 'Should have home item');
$_->ok('./li[2]', sub {
$_->is(
'./a[@href="/"][@title="Catalyst Welcome Page"]',
'Welcome',
'Should have welcome page'
);
}, 'Should have home item');
}, 'Should have menu list');
}, 'Should have menu');
$_->ok('./div[@id="content"]', sub {
$_->is('./span[message]', $msg) if $msg;
$_->is('./span[error]', $err) if $msg;
}, 'Should have content');
}, 'Should have bodyblock');
}

0 comments on commit b171bfb

Please sign in to comment.