From d99ed9bd6a90a01422bee43970930033efdab08d Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Mon, 14 Nov 2005 22:28:47 +0000 Subject: Refactored JavaScriptHelper into PrototypeHelper and ScriptaculousHelper. Added PrototypeHelper::JavaScriptGenerator and PrototypeHelper#update_page for easily modifying multiple elements in an Ajax response. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3036 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../test/template/scriptaculous_helper_test.rb | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 actionpack/test/template/scriptaculous_helper_test.rb (limited to 'actionpack/test/template/scriptaculous_helper_test.rb') diff --git a/actionpack/test/template/scriptaculous_helper_test.rb b/actionpack/test/template/scriptaculous_helper_test.rb new file mode 100644 index 0000000000..fb8f745c7d --- /dev/null +++ b/actionpack/test/template/scriptaculous_helper_test.rb @@ -0,0 +1,61 @@ +require File.dirname(__FILE__) + '/../abstract_unit' + +class ScriptaculousHelperTest < Test::Unit::TestCase + include ActionView::Helpers::JavaScriptHelper + include ActionView::Helpers::PrototypeHelper + include ActionView::Helpers::ScriptaculousHelper + + include ActionView::Helpers::UrlHelper + include ActionView::Helpers::TagHelper + include ActionView::Helpers::TextHelper + include ActionView::Helpers::FormHelper + include ActionView::Helpers::CaptureHelper + + def setup + @controller = Class.new do + def url_for(options, *parameters_for_method_reference) + url = "http://www.example.com/" + url << options[:action].to_s if options and options[:action] + url + end + end.new + end + + def test_effect + assert_equal "new Effect.Highlight('posts',{});", visual_effect(:highlight, "posts") + assert_equal "new Effect.Highlight('posts',{});", visual_effect("highlight", :posts) + assert_equal "new Effect.Highlight('posts',{});", visual_effect(:highlight, :posts) + assert_equal "new Effect.Fade('fademe',{duration:4.0});", visual_effect(:fade, "fademe", :duration => 4.0) + assert_equal "new Effect.Shake(element,{});", visual_effect(:shake) + assert_equal "new Effect.DropOut('dropme',{queue:'end'});", visual_effect(:drop_out, 'dropme', :queue => :end) + end + + def test_sortable_element + assert_dom_equal %(), + sortable_element("mylist", :url => { :action => "order" }) + assert_equal %(), + sortable_element("mylist", :tag => "div", :constraint => "horizontal", :url => { :action => "order" }) + assert_dom_equal %||, + sortable_element("mylist", :containment => ['list1','list2'], :constraint => "horizontal", :url => { :action => "order" }) + assert_dom_equal %(), + sortable_element("mylist", :containment => 'list1', :constraint => "horizontal", :url => { :action => "order" }) + end + + def test_draggable_element + assert_dom_equal %(), + draggable_element('product_13') + assert_equal %(), + draggable_element('product_13', :revert => true) + end + + def test_drop_receiving_element + assert_dom_equal %(), + drop_receiving_element('droptarget1') + assert_dom_equal %(), + drop_receiving_element('droptarget1', :accept => 'products') + assert_dom_equal %(), + drop_receiving_element('droptarget1', :accept => 'products', :update => 'infobox') + assert_dom_equal %(), + drop_receiving_element('droptarget1', :accept => ['tshirts','mugs'], :update => 'infobox') + end +end \ No newline at end of file -- cgit v1.2.3