Skip to content

Commit 6ca0ee5

Browse files
committed
add test for assets being included in html and available
1 parent a7177e7 commit 6ca0ee5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

t/assets.t

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use strict;
2+
use warnings;
3+
use Test::More;
4+
use MetaCPAN::Web::Test qw( app GET test_psgi tx );
5+
6+
test_psgi app, sub {
7+
my $cb = shift;
8+
{
9+
ok( my $res = $cb->( GET '/' ), 'GET /' );
10+
is( $res->code, 200, 'code 200' );
11+
12+
my $xpc = tx($res)->xpc;
13+
14+
my @assets = grep m{^/}, map $_->value,
15+
$xpc->findnodes(q[//script/@src]),
16+
$xpc->findnodes(q[//link[@rel="stylesheet"]/@href]);
17+
18+
ok( ( grep /\.js$/, @assets ), 'assets include a js file' );
19+
ok( ( grep /\.css$/, @assets ), 'assets include a css file' );
20+
21+
for my $asset (@assets) {
22+
ok( my $res = $cb->( GET $asset ), "GET $asset" );
23+
is( $res->code, 200, 'code 200' );
24+
}
25+
}
26+
};
27+
28+
done_testing;

0 commit comments

Comments
 (0)