@@ -29,6 +29,60 @@ class ScrollIntoViewTest < StreamHelperTestCase
2929 assert_dom_equal stream , turbo_stream . scroll_into_view ( "#element" , targets : "#better-element" )
3030 end
3131
32+ test "scroll_into_view with target and align-to-top as positional args" do
33+ stream = %(<turbo-stream align-to-top="true" targets="#element" action="scroll_into_view"><template></template></turbo-stream>)
34+
35+ assert_dom_equal stream , turbo_stream . scroll_into_view ( "#element" , true )
36+ end
37+
38+ test "scroll_into_view with target as positional arg and align-to-top as both arg and kwarg" do
39+ stream = %(<turbo-stream targets="#element" action="scroll_into_view" align-to-top="false"><template></template></turbo-stream>)
40+
41+ assert_dom_equal stream , turbo_stream . scroll_into_view ( "#element" , true , align_to_top : false )
42+ end
43+
44+ test "scroll_into_view with target and align-to-top as positional args and additionl argumenets" do
45+ stream = %(<turbo-stream align-to-top="true" something="else" targets="#element" action="scroll_into_view"><template></template></turbo-stream>)
46+
47+ assert_dom_equal stream , turbo_stream . scroll_into_view ( "#element" , true , something : "else" )
48+ end
49+
50+ test "scroll_into_view with target as positional arg and block as kwarg" do
51+ stream = %(<turbo-stream targets="#element" action="scroll_into_view" block="end"><template></template></turbo-stream>)
52+
53+ assert_dom_equal stream , turbo_stream . scroll_into_view ( "#element" , block : "end" )
54+ end
55+
56+ test "scroll_into_view with target as positional arg and behavior as kwarg" do
57+ stream = %(<turbo-stream targets="#element" action="scroll_into_view" behavior="smooth"><template></template></turbo-stream>)
58+
59+ assert_dom_equal stream , turbo_stream . scroll_into_view ( "#element" , behavior : "smooth" )
60+ end
61+
62+ test "scroll_into_view with target as positional arg and inline as kwarg" do
63+ stream = %(<turbo-stream inline="nearest" action="scroll_into_view" targets="#element"><template></template></turbo-stream>)
64+
65+ assert_dom_equal stream , turbo_stream . scroll_into_view ( "#element" , inline : "nearest" )
66+ end
67+
68+ test "scroll_into_view with target as positional arg and options as kwargs" do
69+ stream = %(<turbo-stream block="end" behavior="smooth" inline="nearest" action="scroll_into_view" targets="#element"><template></template></turbo-stream>)
70+
71+ assert_dom_equal stream , turbo_stream . scroll_into_view ( "#element" , block : "end" , behavior : "smooth" , inline : "nearest" )
72+ end
73+
74+ test "scroll_into_view with target and options as kwargs" do
75+ stream = %(<turbo-stream block="end" behavior="smooth" inline="nearest" action="scroll_into_view" target="#element"><template></template></turbo-stream>)
76+
77+ assert_dom_equal stream , turbo_stream . scroll_into_view ( target : "#element" , block : "end" , behavior : "smooth" , inline : "nearest" )
78+ end
79+
80+ test "scroll_into_view with target, align_to_top and options as kwargs" do
81+ stream = %(<turbo-stream block="end" behavior="smooth" inline="nearest" align-to-top="true" action="scroll_into_view" target="#element"><template></template></turbo-stream>)
82+
83+ assert_dom_equal stream , turbo_stream . scroll_into_view ( target : "#element" , align_to_top : true , block : "end" , behavior : "smooth" , inline : "nearest" )
84+ end
85+
3286 test "scroll_into_view with additional arguments" do
3387 stream = %(<turbo-stream targets="#element" something="else" action="scroll_into_view"><template></template></turbo-stream>)
3488
0 commit comments