-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting custom values on submit buttons (#3141)
- Loading branch information
Showing
4 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/view-components': patch | ||
--- | ||
|
||
Allow setting custom values on submit buttons. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require "lib/test_helper" | ||
|
||
class Primer::Forms::SubmitButtonInputTest < Minitest::Test | ||
include Primer::ComponentTestHelpers | ||
|
||
def test_uses_name_as_value_by_default | ||
render_in_view_context do | ||
primer_form_with(url: "/foo") do |f| | ||
render_inline_form(f) do |submit_button_form| | ||
submit_button_form.submit(name: :foo, label: "Foo") | ||
end | ||
end | ||
end | ||
|
||
assert_selector "button[type=submit][value=Foo]" | ||
end | ||
|
||
def test_allows_overriding_value | ||
render_in_view_context do | ||
primer_form_with(url: "/foo") do |f| | ||
render_inline_form(f) do |submit_button_form| | ||
submit_button_form.submit(name: :foo, label: "Foo", value: "bar") | ||
end | ||
end | ||
end | ||
|
||
assert_selector "button[type=submit][value=bar]" | ||
end | ||
end |