-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for assets being included in html and available
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use MetaCPAN::Web::Test qw( app GET test_psgi tx ); | ||
|
||
test_psgi app, sub { | ||
my $cb = shift; | ||
{ | ||
ok( my $res = $cb->( GET '/' ), 'GET /' ); | ||
is( $res->code, 200, 'code 200' ); | ||
|
||
my $xpc = tx($res)->xpc; | ||
|
||
my @assets = grep m{^/}, map $_->value, | ||
$xpc->findnodes(q[//script/@src]), | ||
$xpc->findnodes(q[//link[@rel="stylesheet"]/@href]); | ||
|
||
ok( (grep /\.js$/, @assets), 'assets include a js file' ); | ||
ok( (grep /\.css$/, @assets), 'assets include a css file' ); | ||
|
||
for my $asset (@assets) { | ||
ok( my $res = $cb->( GET $asset ), "GET $asset" ); | ||
is( $res->code, 200, 'code 200' ); | ||
} | ||
} | ||
}; | ||
|
||
done_testing; |