From 2be3c00863c126f6982d3909a6d792a4a9a25ea6 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 11 Sep 2005 08:40:46 +0000 Subject: Split macros test into their own suite git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2194 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../template/java_script_macros_helper_test.rb | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 actionpack/test/template/java_script_macros_helper_test.rb (limited to 'actionpack/test/template/java_script_macros_helper_test.rb') diff --git a/actionpack/test/template/java_script_macros_helper_test.rb b/actionpack/test/template/java_script_macros_helper_test.rb new file mode 100644 index 0000000000..763eb3d5e9 --- /dev/null +++ b/actionpack/test/template/java_script_macros_helper_test.rb @@ -0,0 +1,52 @@ +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, *parameters_for_method_reference) + 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_equal %(), + auto_complete_field("some_input", :url => { :action => "autocomplete" }); + assert_equal %(), + auto_complete_field("some_input", :url => { :action => "autocomplete" }, :tokens => ','); + assert_equal %(), + auto_complete_field("some_input", :url => { :action => "autocomplete" }, :tokens => [',']); + 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 "