#!perl -T use Test::More 'no_plan'; my $class; BEGIN { $class = 'JavaScript::Framework::jQuery'; use_ok( $class ); } my ( $jquery, $expected, ); $jquery = $class->new( xhtml => 1, library => { src => [ 'jquery.min.js' ], css => [ { href => 'ui.all.css', media => 'screen' } ], }, ); isa_ok($jquery, $class); $expected = ''; $jquery->add_func_calls('// comment'); is($jquery->document_ready, $expected, 'document_ready prints code added with add_func_calls meth'); $jquery = $class->new( xhtml => 1, library => { src => [ 'jquery.min.js' ], css => [ { href => 'ui.all.css', media => 'screen' } ], }, plugins => [ { name => 'mcDropdown', library => { src => [ 'jquery.mcdropdown.js', 'jquery.bgiframe.js' ], css => [ { href => 'jquery.mcdropdown.css', media => 'all' } ], }, }, { name => 'Superfish', library => { src => [ 'superfish.js' ], css => [ { href => 'superfish.css', media => 'all' } ], }, }, ], ); isa_ok($jquery, $class); # test in conjunction with the use of other plugins # Order of operations is important! # The statements created by add_func_calls # and construct_plugin will be included # in the output in the order in which they're # created. $jquery->add_func_calls( q|$('.foobar').do_stuff();| ); $jquery->construct_plugin( name => 'mcDropdown', target_selector => '#inputid', source_ul => '#ulid', ); $jquery->construct_plugin( name => 'Superfish', target_selector => '#divid1', ); $jquery->construct_plugin( name => 'Superfish', target_selector => '#divid2', ); $jquery->construct_plugin( name => 'Superfish', target_selector => '#divid3', ); $expected = ' '; is($jquery->link_elements, $expected, 'output expected LINK elements'); $expected = ' '; is($jquery->script_src_elements, $expected, 'HERE output expected SCRIPT (with SRC attr) elements'); # add CDATA wrapper, since we want XHTML $expected = <<'EOF'; EOF chomp $expected; is($jquery->document_ready, $expected, 'output jQuery $(document).ready(...)');