Skip to content

Commit 9a59f8f

Browse files
committed
added two tests for wrapped file input
1 parent 92676b1 commit 9a59f8f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/bootstrap_form_group_test.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,32 @@ class BootstrapFormGroupTest < ActionView::TestCase
195195
assert_equivalent_html expected, bootstrap_form_for(@user) { |f| f.text_field :email, prepend: "$", append: ".00" }
196196
end
197197

198+
test "file field with prepend text" do
199+
expected = <<~HTML
200+
<div class="mb-3">
201+
<label class="form-label" for="user_avatar">Avatar</label>
202+
<div class="input-group">
203+
<span class="input-group-text">before</span>
204+
<input class="form-control" id="user_avatar" name="user[avatar]" type="file" />
205+
</div>
206+
</div>
207+
HTML
208+
assert_equivalent_html expected, @builder.file_field(:avatar, prepend: "before")
209+
end
210+
211+
test "file field with append text" do
212+
expected = <<~HTML
213+
<div class="mb-3">
214+
<label class="form-label" for="user_avatar">Avatar</label>
215+
<div class="input-group">
216+
<input class="form-control" id="user_avatar" name="user[avatar]" type="file" />
217+
<span class="input-group-text">after</span>
218+
</div>
219+
</div>
220+
HTML
221+
assert_equivalent_html expected, @builder.file_field(:avatar, append: "after")
222+
end
223+
198224
test "help messages for default forms" do
199225
expected = <<~HTML
200226
<div class="mb-3">

0 commit comments

Comments
 (0)