require "#{File.dirname(__FILE__)}/../abstract_unit" class JavaScriptMacrosHelperTest < Test::Unit::TestCase include ActionView::Helpers::JavaScriptHelper include ActionView::Helpers::JavaScriptMacrosHelper 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) url = "http://www.example.com/" url << options[:action].to_s if options and options[:action] url end end @controller = @controller.new end def test_auto_complete_field assert_dom_equal %(), auto_complete_field("some_input", :url => { :action => "autocomplete" }); assert_dom_equal %(), auto_complete_field("some_input", :url => { :action => "autocomplete" }, :tokens => ','); assert_dom_equal %(), auto_complete_field("some_input", :url => { :action => "autocomplete" }, :tokens => [',']); assert_dom_equal %(), auto_complete_field("some_input", :url => { :action => "autocomplete" }, :min_chars => 3); assert_dom_equal %(), auto_complete_field("some_input", :url => { :action => "autocomplete" }, :on_hide => "function(element, update){alert('me');}"); assert_dom_equal %(), auto_complete_field("some_input", :url => { :action => "autocomplete" }, :frequency => 2); assert_dom_equal %(), auto_complete_field("some_input", :url => { :action => "autocomplete" }, :after_update_element => "function(element,value){alert('You have chosen: '+value)}"); assert_dom_equal %(), auto_complete_field("some_input", :url => { :action => "autocomplete" }, :param_name => 'huidriwusch'); end def test_auto_complete_result result = [ { :title => 'test1' }, { :title => 'test2' } ] assert_equal %(), auto_complete_result(result, :title) assert_equal %(), auto_complete_result(result, :title, "est") resultuniq = [ { :title => 'test1' }, { :title => 'test1' } ] assert_equal %(), auto_complete_result(resultuniq, :title, "est") end def test_text_field_with_auto_complete assert_match %(