diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-04-19 14:53:43 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-04-19 14:53:43 -0500 |
commit | a721e51b313310090361f030f65e8334bc3caeef (patch) | |
tree | b2b31440a7fe4570758da4b172d19aa66019ed4f /t | |
parent | 0a9198c691bad4c0d074f0674f1baa1f5a060f57 (diff) | |
download | resource-pack-jquery-a721e51b313310090361f030f65e8334bc3caeef.tar.gz resource-pack-jquery-a721e51b313310090361f030f65e8334bc3caeef.zip |
initial version
Diffstat (limited to 't')
-rw-r--r-- | t/001-bundled.t | 29 | ||||
-rw-r--r-- | t/002-url.t | 95 |
2 files changed, 124 insertions, 0 deletions
diff --git a/t/001-bundled.t b/t/001-bundled.t new file mode 100644 index 0000000..8bb6eb0 --- /dev/null +++ b/t/001-bundled.t @@ -0,0 +1,29 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Cwd; +use File::Temp; +use Path::Class; + +use Resource::Pack::jQuery; + +{ + my $oldcwd = getcwd; + my $dir = File::Temp->newdir; + chdir $dir; + my $file = file('jquery-1.4.2.min.js'); + + my $resource = Resource::Pack::jQuery->new(use_bundled => 1); + ok(!-e $file, "jquery doesn't exist yet"); + $resource->install; + ok(-e $file, "jquery exists!"); + like($file->slurp, qr/jQuery JavaScript Library v1\.4\.2/, + "got the right jquery version"); + like($file->slurp, qr/\Q(function(A,w){function ma(){/, + "got the minified jquery"); + chdir $oldcwd; +} + +done_testing; diff --git a/t/002-url.t b/t/002-url.t new file mode 100644 index 0000000..723cf78 --- /dev/null +++ b/t/002-url.t @@ -0,0 +1,95 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +BEGIN { + plan(skip_all => 'network tests disabled for shipped version') + unless $ENV{RELEASE_TESTING}; +} + +use Cwd; +use File::Temp; +use Path::Class; + +use Resource::Pack::jQuery; + +{ + my $oldcwd = getcwd; + my $dir = File::Temp->newdir; + chdir $dir; + my $file = file('jquery-1.4.2.min.js'); + + my $resource = Resource::Pack::jQuery->new( + version => '1.4.2', + ); + ok(!-e $file, "jquery doesn't exist yet"); + $resource->install; + ok(-e $file, "jquery exists!"); + like($file->slurp, qr/jQuery JavaScript Library v1\.4\.2/, + "got the right jquery version"); + like($file->slurp, qr/\Q(function(A,w){function ma(){/, + "got the minified jquery"); + chdir $oldcwd; +} + +{ + my $oldcwd = getcwd; + my $dir = File::Temp->newdir; + chdir $dir; + my $file = file('jquery-1.4.2.js'); + + my $resource = Resource::Pack::jQuery->new( + version => '1.4.2', + minified => 0, + ); + ok(!-e $file, "jquery doesn't exist yet"); + $resource->install; + ok(-e $file, "jquery exists!"); + like($file->slurp, qr/jQuery JavaScript Library v1\.4\.2/, + "got the right jquery version"); + like($file->slurp, qr:\Qvar jQuery = function(:, + "got the non-minified jquery"); + chdir $oldcwd; +} + +{ + my $oldcwd = getcwd; + my $dir = File::Temp->newdir; + chdir $dir; + my $file = file('jquery-1.3.2.min.js'); + + my $resource = Resource::Pack::jQuery->new( + version => '1.3.2', + ); + ok(!-e $file, "jquery doesn't exist yet"); + $resource->install; + ok(-e $file, "jquery exists!"); + like($file->slurp, qr/jQuery JavaScript Library v1\.3\.2/, + "got the right jquery version"); + like($file->slurp, qr/\Q(function(){var l/, + "got the minified jquery"); + chdir $oldcwd; +} + +{ + my $oldcwd = getcwd; + my $dir = File::Temp->newdir; + chdir $dir; + my $file = file('jquery-1.3.2.js'); + + my $resource = Resource::Pack::jQuery->new( + version => '1.3.2', + minified => 0, + ); + ok(!-e $file, "jquery doesn't exist yet"); + $resource->install; + ok(-e $file, "jquery exists!"); + like($file->slurp, qr/jQuery JavaScript Library v1\.3\.2/, + "got the right jquery version"); + like($file->slurp, qr:\QjQuery.fn = jQuery.prototype = {:, + "got the non-minified jquery"); + chdir $oldcwd; +} + +done_testing; |