From a721e51b313310090361f030f65e8334bc3caeef Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 19 Apr 2010 14:53:43 -0500 Subject: initial version --- t/001-bundled.t | 29 ++++++++++++++++++ t/002-url.t | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 t/001-bundled.t create mode 100644 t/002-url.t (limited to 't') 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; -- cgit v1.2.3-54-g00ecf