| File: | t/4-auto_minify.t |
| Coverage: | 100.0% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | 1 1 1 | 1272034657862132 12882 9 | use Test::More; | ||||
| 2 | 1 1 1 | 421 946 39 | use FindBin; | ||||
| 3 | 1 1 1 | 164 676 8 | use lib "$FindBin::Bin/lib"; | ||||
| 4 | |||||||
| 5 | 1 1 1 | 270 487767 8 | use Catalyst::Test 'TestApp'; | ||||
| 6 | |||||||
| 7 | # | ||||||
| 8 | # sanity check first -- controller | ||||||
| 9 | # | ||||||
| 10 | 1 | 529876 | my $controller = TestApp->controller('JsMin'); | ||||
| 11 | 1 | 110 | is( ref($controller), 'TestApp::Controller::JsMin', 'Controller is OK'); | ||||
| 12 | 1 | 569 | can_ok($controller => 'minify'); | ||||
| 13 | |||||||
| 14 | # | ||||||
| 15 | # get a context object | ||||||
| 16 | # | ||||||
| 17 | 1 | 322 | like( get('/jsmin/js1.js'), | ||||
| 18 | qr{\A \# \s+ /\* \s+ javascript \s+ 1 \s+ \*/ \s+ \# \s* \z}xms, | ||||||
| 19 | 'minified JavaScript looks OK' ); | ||||||
| 20 | |||||||
| 21 | # | ||||||
| 22 | # now see if the failing controller really fails | ||||||
| 23 | # well it does not fail, it does not minify | ||||||
| 24 | # | ||||||
| 25 | 1 | 267 | my $failing_controller = TestApp->controller('JsFail'); | ||||
| 26 | 1 | 93 | is( ref($failing_controller), 'TestApp::Controller::JsFail', 'Controller is OK'); | ||||
| 27 | 1 | 430 | ok(!UNIVERSAL::can($failing_controller,'minify'), 'failing controller has no "minify" routine'); | ||||
| 28 | |||||||
| 29 | 1 | 222 | like( get('/jsfail/js1.js'), | ||||
| 30 | qr{\A \s* /\* \s+ javascript \s+ 1 \s+ \*/ \s* \z}xms, | ||||||
| 31 | 'want-minified JavaScript is not minified' ); | ||||||
| 32 | |||||||
| 33 | 1 | 261 | done_testing; | ||||