diff --git a/test/form_builder/hint_test.rb b/test/form_builder/hint_test.rb index af915611..ca783676 100644 --- a/test/form_builder/hint_test.rb +++ b/test/form_builder/hint_test.rb @@ -141,29 +141,4 @@ class HintTest < ActionView::TestCase assert_select 'div.omg_hint', "can't be blank" end end - - test 'optional hint displays when given' do - swap_wrapper :default, self.custom_wrapper_with_optional_div do - with_form_for @user, :name, hint: "can't be blank" - assert_select 'section.custom_wrapper div.no_output_wrapper p.omg_hint', "can't be blank" - assert_select 'p.omg_hint' - end - end - - test 'optional hint displays empty wrapper when no hint given' do - swap_wrapper :default, self.custom_wrapper_with_optional_div do - with_form_for @user, :name - assert_select 'section.custom_wrapper div.no_output_wrapper' - assert_no_select 'p.omg_hint' - end - end - - test 'optional hint displays no wrapper or hint when no hint and override is given' do - swap_wrapper :default, self.custom_wrapper_with_optional_div_and_override do - with_form_for @user, :name - assert_no_select 'section.custom_wrapper div.no_output_wrapper' - assert_no_select 'div.no_output_wrapper' - assert_no_select 'p.omg_hint' - end - end end diff --git a/test/form_builder/wrapper_test.rb b/test/form_builder/wrapper_test.rb index 3f157c04..1393d006 100644 --- a/test/form_builder/wrapper_test.rb +++ b/test/form_builder/wrapper_test.rb @@ -267,4 +267,38 @@ class WrapperTest < ActionView::TestCase assert_select "div.custom_wrapper input.string[data-modal=true]" end + + test 'inline wrapper displays when there is content' do + swap_wrapper :default, self.custom_wrapper_with_optional_div do + with_form_for @user, :name, hint: "can't be blank" + assert_select 'section.custom_wrapper div.no_output_wrapper p.omg_hint', "can't be blank" + assert_select 'p.omg_hint' + end + end + + test 'inline wrapper does not display when there is no content' do + swap_wrapper :default, self.custom_wrapper_with_optional_div do + with_form_for @user, :name + assert_select 'section.custom_wrapper div.no_output_wrapper' + assert_no_select 'p.omg_hint' + end + end + + test 'optional wrapper does not display when there is content' do + swap_wrapper :default, self.custom_wrapper_with_optional_div_and_override do + with_form_for @user, :name, hint: "can't be blank" + assert_select 'section.custom_wrapper div.no_output_wrapper' + assert_select 'div.no_output_wrapper' + assert_select 'p.omg_hint' + end + end + + test 'optional wrapper does not display when there is no content' do + swap_wrapper :default, self.custom_wrapper_with_optional_div_and_override do + with_form_for @user, :name + assert_no_select 'section.custom_wrapper div.no_output_wrapper' + assert_no_select 'div.no_output_wrapper' + assert_no_select 'p.omg_hint' + end + end end