1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Add specs for required option when not using browser validations

This commit is contained in:
Petr Gazarov 2016-08-13 16:34:02 -04:00
parent 9726447bbc
commit a5f94ba38b

View file

@ -34,6 +34,38 @@ class RequiredTest < ActionView::TestCase
with_input_for @user, :name, :string
assert_select 'input[type=text].required'
assert_no_select 'input[type=text][required]'
assert_no_select 'input[type=text][aria-required]'
end
end
test 'when not using browser validations, when required option is set to false, input does not generate required html attribute' do
swap SimpleForm, browser_validations: false do
with_input_for @user, :name, :string, required: false
assert_no_select 'input[type=text].required'
assert_no_select 'input[type=text][required]'
assert_no_select 'input[type=text][aria-required]'
end
end
test 'when not using browser validations, when required option is set to true, input generates required html attribute' do
swap SimpleForm, browser_validations: false do
with_input_for @user, :name, :string, required: true
assert_select 'input[type=text].required'
assert_select 'input[type=text][required]'
assert_select 'input[type=text][aria-required]'
end
end
test 'when not using browser validations, when required option is true in the wrapper, input does not generate required html attribute' do
swap SimpleForm, browser_validations: false do
swap_wrapper :default, self.custom_wrapper_with_required_input do
with_concat_form_for(@user) do |f|
concat f.input :name
end
assert_select 'input[type=text].required'
assert_no_select 'input[type=text][required]'
assert_no_select 'input[type=text][aria-required]'
end
end
end