8 $ENV{SGN_SKIP_CGI} = 1; #< don't need to compile all the CGIs
9 use_ok 'Catalyst::Test', 'SGN';
10 use_ok 'SGN::Controller::JavaScript';
13 my $controller = SGN->controller('JavaScript');
15 my ($res, $c) = ctx_request('/');
17 { # test serving a JS package
18 my $test_uri = $c->uri_for( $controller->action_for_js_package([ 'sgn.js', 'jquery.js', 'Text.Markup' ]));
19 like( $test_uri, qr! js/pack/[a-z\d]+$ !x, 'got a kosher-looking pack URI' );
21 ($res, $c) = ctx_request( $test_uri );
22 cmp_ok( length($res->content), '>', 8000, 'got a big-looking response' )
23 or diag "response was actually:\n", explain $res;
25 like( $res->content, qr/jQuery/, 'there is some jquery in it' );
26 like( $res->content, qr/Text\.Markup/, 'there is some Text.Markup in it' );
29 { # test serving a single JS file
31 like( get( '/js/Text/Markup.js' ), qr/function\s*\(/,
32 'served a single JS file',
37 $res = request( $c->uri_for( '/js/Nonexistent.js' ));
38 } qr/Can't open .+Nonexistent.js/, 'got a warning about the missing file';
41 'nonexistent js says not found',
44 is( $res->code, 404, 'gives a 404' );